|
|
back to boardWA on Test #2 Posted by AKS 5 Aug 2008 03:47 Help me please! What's the 2nd test? #include <iostream> using namespace std; int main(int argc, char *argv[]) { int N; int a[11][11] = {0}; cin >> N; int xi, yi; for (int i = 0; i < N; i++) { cin >> xi >> yi; a[xi][yi] = 1; } int x[102] = {0}; int y[102] = {0}; int x0; int y0; int s, l; for (int i = 1; i <= 10; i++) { for (int j = 1; j <= 10; j++) { if (a[i][j]) { cout << i << ' ' << j << endl; s = 1; l = 1; x[1] = i; y[1] = j; while ((l < N) && (x[l])) { x0 = x[l]; y0 = y[l]; //cout << x0 << '.' << y0 << " : "; a[x0][y0] = 0; if ((x0 < 10) && (a[x0+1][y0])) { cout << 'R'; a[x0+1][y0] = 0; s++; x[s] = x0+1; y[s] = y0; } if ((y0 < 10) && (a[x0][y0+1])) { cout << 'T'; a[x0][y0+1] = 0; s++; x[s] = x0; y[s] = y0+1; } if ((x0 > 1) && (a[x0-1][y0])) { cout << 'L'; a[x0-1][y0] = 0; s++; x[s] = x0-1; y[s] = y0; } if ((y0 > 1) && (a[x0][y0-1])) { cout << 'B'; a[x0][y0-1] = 0; s++; x[s] = x0; y[s] = y0-1; } l++; cout << ',' << endl; } } } } cout << '.'; return 0; } |
|
|