Submission #1195001

#TimeUsernameProblemLanguageResultExecution timeMemory
1195001nikulidIdeal city (IOI12_city)C++20
Compilation error
0 ms0 KiB
#include <climits> /* lemma: I will solve subtask 4 */ ll ans=0; vector<vector<int>> visitted, exists; // both are [y][x] int bfs(int I, int x, int y, int curdist){ // coords is [x,y] visitted[y][x] = I; ans = ans%1000000000; if(exists[y+1][x+1] && visitted[y+1][x+1] != I){ ans += curdist+1; bfs(I, x+1, y+1, curdist+1); } if(exists[y+1][x-1] && visitted[y+1][x-1] != I){ ans += curdist+1; bfs(I, x-1, y+1, curdist+1); } if(exists[y-1][x+1] && visitted[y-1][x+1] != I){ ans += curdist+1; bfs(I, x+1, y-1, curdist+1); } if(exists[y-1][x-1] && visitted[y-1][x-1] != I){ ans += curdist+1; bfs(I, x-1, y-1, curdist+1); } return; } int DistanceSum(int N, int *X, int *Y) { visitted = vector<vector<int>>(N+1, N+1, 0); exists = vector<vector<int>>(N+1, N+1, 0); // find min X and Y values, to translate the graph to start at (1,1) int minX=INT_MAX-1, minY=INT_MAX-1; for(int i=0; i<N; i++){ minX = min(minX, X[i]); minY = min(minY, Y[i]); } for(int i=0; i<N; i++){ exists[Y[i]-minY][X[i]-minX] = 1; } for(int i=0; i<N; i++){ bfs(i, X[i], Y[i], 0); } return ans; }

Compilation message (stderr)

city.cpp:8:1: error: 'll' does not name a type
    8 | ll ans=0;
      | ^~
city.cpp:9:8: error: 'vector' was not declared in this scope
    9 | vector<vector<int>> visitted, exists; // both are [y][x]
      |        ^~~~~~
city.cpp:9:8: error: 'vector' was not declared in this scope
city.cpp:9:8: error: 'vector' was not declared in this scope
city.cpp:9:8: error: 'vector' was not declared in this scope
city.cpp:9:8: error: 'vector' was not declared in this scope
city.cpp:9:8: error: 'vector' was not declared in this scope
city.cpp:9:8: error: 'vector' was not declared in this scope
city.cpp:9:8: error: 'vector' was not declared in this scope
city.cpp:9:8: error: 'vector' was not declared in this scope
city.cpp:9:1: error: 'vector' does not name a type
    9 | vector<vector<int>> visitted, exists; // both are [y][x]
      | ^~~~~~
city.cpp: In function 'int bfs(int, int, int, int)':
city.cpp:13:3: error: 'visitted' was not declared in this scope
   13 |   visitted[y][x] = I;
      |   ^~~~~~~~
city.cpp:14:3: error: 'ans' was not declared in this scope
   14 |   ans = ans%1000000000;
      |   ^~~
city.cpp:15:6: error: 'exists' was not declared in this scope
   15 |   if(exists[y+1][x+1] && visitted[y+1][x+1] != I){
      |      ^~~~~~
city.cpp:19:6: error: 'exists' was not declared in this scope
   19 |   if(exists[y+1][x-1] && visitted[y+1][x-1] != I){
      |      ^~~~~~
city.cpp:23:6: error: 'exists' was not declared in this scope
   23 |   if(exists[y-1][x+1] && visitted[y-1][x+1] != I){
      |      ^~~~~~
city.cpp:27:6: error: 'exists' was not declared in this scope
   27 |   if(exists[y-1][x-1] && visitted[y-1][x-1] != I){
      |      ^~~~~~
city.cpp:31:3: error: return-statement with no value, in function returning 'int' [-fpermissive]
   31 |   return;
      |   ^~~~~~
city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:36:3: error: 'visitted' was not declared in this scope
   36 |   visitted = vector<vector<int>>(N+1, N+1, 0);
      |   ^~~~~~~~
city.cpp:36:21: error: 'vector' was not declared in this scope
   36 |   visitted = vector<vector<int>>(N+1, N+1, 0);
      |                     ^~~~~~~~~~~~
city.cpp:36:21: error: 'vector' was not declared in this scope
city.cpp:37:3: error: 'exists' was not declared in this scope
   37 |   exists = vector<vector<int>>(N+1, N+1, 0);
      |   ^~~~~~
city.cpp:37:26: error: expected primary-expression before 'int'
   37 |   exists = vector<vector<int>>(N+1, N+1, 0);
      |                          ^~~
city.cpp:42:12: error: 'min' was not declared in this scope; did you mean 'minY'?
   42 |     minX = min(minX, X[i]);
      |            ^~~
      |            minY
city.cpp:53:10: error: 'ans' was not declared in this scope
   53 |   return ans;
      |          ^~~