Submission #252915

# Submission time Handle Problem Language Result Execution time Memory
252915 2020-07-26T12:44:30 Z Erkhemkhuu Land of the Rainbow Gold (APIO17_rainbow) C++17
Compilation error
0 ms 0 KB
int x0, y0, x1, y1;
    x0 = ar; y0 = ac;
    x1 = br; y1 = bc;
    int N = x1 - x0 + 1;
    int M = y1 - y0 + 1;
    int i, j;
    char temp[sN][sN];
    for(i = x0; i <= x1; i++)
        for(j = y0; j <= y1; j++)
            temp[i - x0 + 1][j - y0 + 1] = grid[i][j];
    int cnt = 0;
    for(i = 1; i <= N; i++) {
        for(j = 1; j <= M; j++) {
            if(temp[i][j] == '0') {
                cnt++;
                queue <int> q;
                q.push(i * 1000 + j);
                while(!q.empty()) {
                    int v = q.front();
                    int curx = v / 1000;
                    int cury = v % 1000;
                    q.pop();
                    temp[curx][cury] = 'M';
                    if(curx - 1 >= 1 && temp[curx - 1][cury] == '0') q.push((curx - 1) * 1000 + cury);
                    if(cury + 1 <= M && temp[curx][cury + 1] == '0') q.push(curx * 1000 + cury + 1);
                    if(curx + 1 <= N && temp[curx + 1][cury] == '0') q.push((curx + 1) * 1000 + cury);
                    if(cury - 1 >= 1 && temp[curx][cury - 1] == '0') q.push(curx * 1000 + cury - 1);
                }
            }
        }
    }
    return cnt;

Compilation message

rainbow.cpp:2:5: error: 'x0' does not name a type
     x0 = ar; y0 = ac;
     ^~
rainbow.cpp:2:14: error: 'y0' does not name a type
     x0 = ar; y0 = ac;
              ^~
rainbow.cpp:3:5: error: 'x1' does not name a type
     x1 = br; y1 = bc;
     ^~
rainbow.cpp:3:14: error: 'y1' does not name a type
     x1 = br; y1 = bc;
              ^~
rainbow.cpp:7:15: error: 'sN' was not declared in this scope
     char temp[sN][sN];
               ^~
rainbow.cpp:7:15: note: suggested alternative: 'N'
     char temp[sN][sN];
               ^~
               N
rainbow.cpp:7:19: error: 'sN' was not declared in this scope
     char temp[sN][sN];
                   ^~
rainbow.cpp:7:19: note: suggested alternative: 'N'
     char temp[sN][sN];
                   ^~
                   N
rainbow.cpp:8:5: error: expected unqualified-id before 'for'
     for(i = x0; i <= x1; i++)
     ^~~
rainbow.cpp:8:17: error: 'i' does not name a type
     for(i = x0; i <= x1; i++)
                 ^
rainbow.cpp:8:26: error: 'i' does not name a type
     for(i = x0; i <= x1; i++)
                          ^
rainbow.cpp:9:21: error: 'j' does not name a type
         for(j = y0; j <= y1; j++)
                     ^
rainbow.cpp:9:30: error: 'j' does not name a type
         for(j = y0; j <= y1; j++)
                              ^
rainbow.cpp:12:5: error: expected unqualified-id before 'for'
     for(i = 1; i <= N; i++) {
     ^~~
rainbow.cpp:12:16: error: 'i' does not name a type
     for(i = 1; i <= N; i++) {
                ^
rainbow.cpp:12:24: error: 'i' does not name a type
     for(i = 1; i <= N; i++) {
                        ^
rainbow.cpp:32:5: error: expected unqualified-id before 'return'
     return cnt;
     ^~~~~~