Submission #252891

#TimeUsernameProblemLanguageResultExecution timeMemory
252891Erkhemkhuu무지개나라 (APIO17_rainbow)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define F first #define S second const ll N = 105; void init(ll n, ll m, ll sz, ll q, ll curx, ll cury, string path) { char grid[N][N]; for(i = 0; i <= n; i++) for(j = 0; j <= m; j++) grid[i][j] = '0'; for(i = 0; i < sz; i++) { if(path[i] == 'N') grid[--curx][cury] = 'X'; if(path[i] == 'E') grid[curx][++cury] = 'X'; if(path[i] == 'S') grid[++curx][cury] = 'X'; if(path[i] == 'W') grid[curx][--cury] = 'X'; } while(q--) { colours(x0, y0, x1, y1); ll N = x1 - x0 + 1; ll M = y1 - y0 + 1; char temp[N][N]; for(i = x0; i <= x1; i++) for(j = y0; j <= y1; j++) temp[i - x0 + 1][j - y0 + 1] = grid[i][j]; ll cnt = 0; for(i = 1; i <= N; i++) { for(j = 1; j <= M; j++) { if(temp[i][j] == '0') { cnt++; queue <ll> q; q.push(i * 1000 + j); while(!q.empty()) { ll v = q.front(); curx = v / 1000; 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); } } } } cout << cnt << "\n"; } return; }

Compilation message (stderr)

rainbow.cpp: In function 'void init(long long int, long long int, long long int, long long int, long long int, long long int, std::__cxx11::string)':
rainbow.cpp:11:9: error: 'i' was not declared in this scope
     for(i = 0; i <= n; i++)
         ^
rainbow.cpp:12:13: error: 'j' was not declared in this scope
         for(j = 0; j <= m; j++)
             ^
rainbow.cpp:14:9: error: 'i' was not declared in this scope
     for(i = 0; i < sz; i++) {
         ^
rainbow.cpp:21:17: error: 'x0' was not declared in this scope
         colours(x0, y0, x1, y1);
                 ^~
rainbow.cpp:21:17: note: suggested alternative: 'y0'
         colours(x0, y0, x1, y1);
                 ^~
                 y0
rainbow.cpp:21:25: error: 'x1' was not declared in this scope
         colours(x0, y0, x1, y1);
                         ^~
rainbow.cpp:21:25: note: suggested alternative: 'y1'
         colours(x0, y0, x1, y1);
                         ^~
                         y1
rainbow.cpp:21:9: error: 'colours' was not declared in this scope
         colours(x0, y0, x1, y1);
         ^~~~~~~
rainbow.cpp:23:19: error: ISO C++ forbids using pointer to a function in subtraction [-fpermissive]
         ll M = y1 - y0 + 1;
                ~~~^~~~
rainbow.cpp:25:13: error: 'i' was not declared in this scope
         for(i = x0; i <= x1; i++)
             ^
rainbow.cpp:26:17: error: 'j' was not declared in this scope
             for(j = y0; j <= y1; j++)
                 ^
rainbow.cpp:29:13: error: 'i' was not declared in this scope
         for(i = 1; i <= N; i++) {
             ^
rainbow.cpp:30:17: error: 'j' was not declared in this scope
             for(j = 1; j <= M; j++) {
                 ^