Submission #673217

# Submission time Handle Problem Language Result Execution time Memory
673217 2022-12-20T00:16:58 Z dooompy Navigation 2 (JOI21_navigation2) C++17
Compilation error
0 ms 0 KB
int cur[105][105];
    bool seen[15];
    int n;
 
    void Anna(int N, int K, vector<int> R, vector<int> C) {
        n = N;
 
        bool valid = true;
        // cout << "BRUH" << endl;
        for (int offset = 0; offset < 9; offset++) {
//            cout << offset << endl;
            valid = true;
 
            for (int i = 0; i < N; i++) {
                if (!valid) break;
                for (int j = 0; j < N; j++) {
                    if (!valid) break;
                    int dx = offset / 3;
                    int dy = offset % 3;
 
                    int nx = i + dx, ny = j + dy;
 
                    int equival = ((nx) % 3) * 3 + (ny) % 3;
 
                   cout << equival << " ";
                    if (equival == 8) {
                        // anchor point
                        cur[i][j] = 1e9;
                    } else if (equival == 7) {
                        // store val for later
                        cur[i][j] = -1;
                    } else {
 
                        int ndx = - R[equival] + i, ndy = - C[equival] + j;
 
                        if (ndx >= 2) {
                            cur[i][j] = 12;
                        } else if (ndy >= 2) {
                            cur[i][j] = 10;
                        } else if (ndx <= -2) {
                            cur[i][j] = 11;
                        } else if (ndy <= -2) {
                            cur[i][j] = 9;
                        } else {
                            cur[i][j] = (ndx + 1) * 3 + ndy + 2;
                            if (cur[i][j] == 9) {
                                valid = false;
                                break;
                            }
//                            if (cur[i][j] > 5) cur[i][j]--;
                        }
 
                    }
 
                    // cout << cur[i][j] << " " ;
                }
               cout << endl;
            }
 
            if (valid) break;
 
        }
        assert(valid == true);
 
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (cur[i][j] == 1e9 || cur[i][j] == -1) continue;
                assert(cur[i][j] != 0);
                seen[cur[i][j]] = true;
            }
        }
 
        int skipval = -1;
 
        for (int i = 1; i <= 12; i++) {
            if (!seen[i]) {
                skipval = i;
                break;
            }
        }

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                cout << cur[i][j] << " ";
            }
            cout << endl;
        }

        cout << endl;
 
//        assert(skipval > 0);
        // cout << skipval << endl;
 
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (cur[i][j] == 1e9) {
                    SetFlag(i, j, 12);
                } else if (cur[i][j] == -1) {
                    SetFlag(i, j, skipval);
                } else {
                    if (cur[i][j] > skipval) cur[i][j]--;
                    SetFlag(i, j, cur[i][j]);
                }
            }
        }
        // cout << "BRUH" << endl;
 
    }
vector<int> Bruno(int K, vector<int> value) {
        // cout << "Called " << endl;
        int anchor = 0;
        int dx, dy;
        for (int i = 0; i < 9; i++) {
            if (value[i] == 12) {
                anchor = i;
                dx = i / 3, dy = i % 3;
            }
        }
 
        // for (int i =0 ; i < 9; i++) cout << value[i] << " ";
        // cout << endl;
 
        int skipped = value[dx * 3 + ((dy + 2) % 3)];
 
        // cout << skipped << endl;
//        cout << value[7] << " " << value[8] << endl;
 
        vector<int> ans(K, 0);
 
        for (int i = 0; i < 9; i++) {
            if (value[i] == skipped || value[i] == 12) continue;
 
            int ni = (i / 3 + 2 - dx) % 3, nj = (i % 3 + 2 - dy) % 3;
 
            cout << value[i] << endl;
            int equival = (ni * 3 + nj);
//            cout << "equiv " <<  equival << endl;
//            if (equival >= 8) assert(false);
 
            if (value[i] >= skipped) value[i]++;
            if (equival >= 7) continue;
 
            if (value[i] >= 9) ans[equival] = value[i] - 9;
            else {
                int r = (i / 3) + (1 - (value[i]- 1) / 3);
                int c = (i % 3) + (1 - (value[i]- 1) % 3);
 
               cout << i << " " << value[i] << " " <<  r << " " << c << endl;
 
                if (1 == r && 1 == c) ans[equival] = 4;
                else if (r < 1) ans[equival] = 3;
                else if (c < 1) ans[equival] = 1;
                else if (r > 1) ans[equival] = 2;
                else if (c > 1) ans[equival] = 0;
            }
        }

        for (int i = 0; i < 7; i++) {
            cout << ans[i] << " ";
        }
 
        cout << endl;

        return ans;
 
        // cout << endl;
 
        // return vector<int>(K, 0);
        // assert(false);
    }

Compilation message

Anna.cpp:5:29: error: 'vector' has not been declared
    5 |     void Anna(int N, int K, vector<int> R, vector<int> C) {
      |                             ^~~~~~
Anna.cpp:5:35: error: expected ',' or '...' before '<' token
    5 |     void Anna(int N, int K, vector<int> R, vector<int> C) {
      |                                   ^
Anna.cpp: In function 'void Anna(int, int, int)':
Anna.cpp:25:20: error: 'cout' was not declared in this scope
   25 |                    cout << equival << " ";
      |                    ^~~~
Anna.cpp:34:37: error: 'R' was not declared in this scope
   34 |                         int ndx = - R[equival] + i, ndy = - C[equival] + j;
      |                                     ^
Anna.cpp:38:36: error: 'ndy' was not declared in this scope; did you mean 'ndx'?
   38 |                         } else if (ndy >= 2) {
      |                                    ^~~
      |                                    ndx
Anna.cpp:57:16: error: 'cout' was not declared in this scope
   57 |                cout << endl;
      |                ^~~~
Anna.cpp:57:24: error: 'endl' was not declared in this scope
   57 |                cout << endl;
      |                        ^~~~
Anna.cpp:63:9: error: 'assert' was not declared in this scope
   63 |         assert(valid == true);
      |         ^~~~~~
Anna.cpp:1:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
  +++ |+#include <cassert>
    1 | int cur[105][105];
Anna.cpp:84:17: error: 'cout' was not declared in this scope
   84 |                 cout << cur[i][j] << " ";
      |                 ^~~~
Anna.cpp:86:13: error: 'cout' was not declared in this scope
   86 |             cout << endl;
      |             ^~~~
Anna.cpp:86:21: error: 'endl' was not declared in this scope
   86 |             cout << endl;
      |                     ^~~~
Anna.cpp:89:9: error: 'cout' was not declared in this scope
   89 |         cout << endl;
      |         ^~~~
Anna.cpp:89:17: error: 'endl' was not declared in this scope
   89 |         cout << endl;
      |                 ^~~~
Anna.cpp:97:21: error: 'SetFlag' was not declared in this scope
   97 |                     SetFlag(i, j, 12);
      |                     ^~~~~~~
Anna.cpp:99:21: error: 'SetFlag' was not declared in this scope
   99 |                     SetFlag(i, j, skipval);
      |                     ^~~~~~~
Anna.cpp:102:21: error: 'SetFlag' was not declared in this scope
  102 |                     SetFlag(i, j, cur[i][j]);
      |                     ^~~~~~~

Bruno.cpp:1:1: error: 'vector' does not name a type
    1 | vector<int> Bruno(int K, vector<int> value) {
      | ^~~~~~