|
|
вернуться в форумWhy Access Violation 22? Послано Denis 18 окт 2007 01:21 #include <fstream> #include <stdio.h> #include <vector> using namespace std; int n, r, num = 0, g; int arr[100100] = {0}; vector <int> v[100100]; bool can[100100] = {0}; int pr[100100] = {0}; int pr_val[100100] = {0}; int nm[100100] = {0}; int fset (int x) { int i; /*for (i = x; i > 0; --i) { if (!can[i]) { return i; } } return 0;*/ if (!can[x]) { return x; } int t = pr[x]; pr[x] = fset (t); return pr[x]; ++g; } int main () { //freopen ("a.in", "r", stdin); //freopen ("a.out", "w", stdout); int i, j = 0, t; scanf ("%d%d", &n, &r); arr[0] = -110000000; for (i = 1; i <= n; ++i) { scanf ("%d", &arr[i]); while (arr[i]-arr[j] > r) { ++j; } --j; pr[i] = i-1; pr_val[i] = j; } for (i = 1; i <= n; ++i) { j = pr_val[i]; g = 0; t = fset (j); if (t == 0) { num++; v[num].push_back (i); nm[i] = num; } else { can[t] = true; v[nm[t]].push_back (i); nm[i] = nm[t]; } } printf ("%d\n", num); int col = 0; for (i = 1; i <= num; ++i) { printf ("%d ", v[i].size()); for (j = 0; j < v[i].size()-1; ++j) { printf ("%d ", v[i][j]); ++col; if (v[i][j]+r >= v[i][j+1]) { int q = 1; q = q/(1-q); } } printf ("%d\n", v[i][v[i].size()-1]); ++col; } if (col != n) { int q = 1; q = q/(1-q); } return 0; } Edited by author 18.10.2007 02:24 Re: Why Access Violation 22? I had WA 22 using 'long' type. When I used 'long long' I got AC. Re: Why Access Violation 22? Denis, It is siple!!!!! Change string arr[0] = -110000000; on arr[0] = -1100000000; and be happy=) |
|
|