Submission #1003301

#TimeUsernameProblemLanguageResultExecution timeMemory
1003301Nailuj_217Dijamant (COCI22_dijamant)C++17
Compilation error
0 ms0 KiB
const l INF = 1LL<<15; array<vector<l>, 2005> rows; array<l, 2005> positions; int main() { l n, m; cin >> n >> m; string row; l sum = 0; for (int i = 1; i <= n; i++) { cin >> row; for (int j = 0; j < row.size(); j++) { if (row[j] == '#') rows[i].push_back(j+1); } } l dist_to_left; for (int i = 2; i < n; i++) { positions.fill(0); for (int j = 1; j < m; j++) { for (int k = 1; k <= n; k++) { if (positions[k] != INF && rows[k][positions[k]] < j) { if (rows[k].size() > positions[k]+1) positions[k]++; else positions[k] = INF; } } if (!positions[i]) continue; if (positions[i] == INF) continue; dist_to_left = j - rows[i][positions[i]-1]; if (i - dist_to_left < 1 || i + dist_to_left > n || j + dist_to_left > m) continue; if (j + dist_to_left != rows[i][positions[i]]) continue; l c = 0; bool is_valid = true; for (int k = i - dist_to_left; k < i; k++) { assert(k > 0); if (positions[k] == INF) { is_valid = false; break; } if (c == 0) { if (rows[k][positions[k]] != j) { is_valid = false; break; } } else { if (positions[k] == 0 || rows[k][positions[k]-1] != j-c) { is_valid = false; break; } if (positions[k] == 0 || rows[k][positions[k]] != j+c) { is_valid = false; break; } } c++; } c = 0; for (int k = i + dist_to_left; k > i; k--) { assert(k <= n); if (positions[k] == INF) { is_valid = false; break; } if (c == 0) { if (rows[k][positions[k]] != j) { is_valid = false; break; } } else { if (positions[k] == 0 || rows[k][positions[k]-1] != j-c) { is_valid = false; break; } if (positions[k] == 0 || rows[k][positions[k]] != j+c) { is_valid = false; break; } } c++; } if (is_valid) { sum++; } } } cout << sum << endl; return 0; }

Compilation message (stderr)

Main.cpp:1:7: error: 'l' does not name a type
    1 | const l INF = 1LL<<15;
      |       ^
Main.cpp:3:1: error: 'array' does not name a type
    3 | array<vector<l>, 2005> rows;
      | ^~~~~
Main.cpp:4:1: error: 'array' does not name a type
    4 | array<l, 2005> positions;
      | ^~~~~
Main.cpp: In function 'int main()':
Main.cpp:10:5: error: 'l' was not declared in this scope
   10 |     l n, m;
      |     ^
Main.cpp:11:5: error: 'cin' was not declared in this scope
   11 |     cin >> n >> m;
      |     ^~~
Main.cpp:11:12: error: 'n' was not declared in this scope
   11 |     cin >> n >> m;
      |            ^
Main.cpp:11:17: error: 'm' was not declared in this scope
   11 |     cin >> n >> m;
      |                 ^
Main.cpp:12:5: error: 'string' was not declared in this scope
   12 |     string row;
      |     ^~~~~~
Main.cpp:14:6: error: expected ';' before 'sum'
   14 |     l sum = 0;
      |      ^~~~
      |      ;
Main.cpp:17:16: error: 'row' was not declared in this scope
   17 |         cin >> row;
      |                ^~~
Main.cpp:19:32: error: 'rows' was not declared in this scope
   19 |             if (row[j] == '#') rows[i].push_back(j+1);
      |                                ^~~~
Main.cpp:22:6: error: expected ';' before 'dist_to_left'
   22 |     l dist_to_left;
      |      ^~~~~~~~~~~~~
      |      ;
Main.cpp:25:9: error: 'positions' was not declared in this scope
   25 |         positions.fill(0);
      |         ^~~~~~~~~
Main.cpp:28:37: error: 'INF' was not declared in this scope
   28 |                 if (positions[k] != INF && rows[k][positions[k]] < j) {
      |                                     ^~~
Main.cpp:28:44: error: 'rows' was not declared in this scope
   28 |                 if (positions[k] != INF && rows[k][positions[k]] < j) {
      |                                            ^~~~
Main.cpp:34:33: error: 'INF' was not declared in this scope
   34 |             if (positions[i] == INF) continue;
      |                                 ^~~
Main.cpp:35:13: error: 'dist_to_left' was not declared in this scope
   35 |             dist_to_left = j - rows[i][positions[i]-1];
      |             ^~~~~~~~~~~~
Main.cpp:35:32: error: 'rows' was not declared in this scope
   35 |             dist_to_left = j - rows[i][positions[i]-1];
      |                                ^~~~
Main.cpp:40:14: error: expected ';' before 'c'
   40 |             l c = 0;
      |              ^~
      |              ;
Main.cpp:43:17: error: 'assert' was not declared in this scope
   43 |                 assert(k > 0);
      |                 ^~~~~~
Main.cpp:1:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
  +++ |+#include <cassert>
    1 | const l INF = 1LL<<15;
Main.cpp:44:37: error: 'INF' was not declared in this scope
   44 |                 if (positions[k] == INF) {
      |                                     ^~~
Main.cpp:48:21: error: 'c' was not declared in this scope
   48 |                 if (c == 0) {
      |                     ^
Main.cpp:63:17: error: 'c' was not declared in this scope
   63 |                 c++;
      |                 ^
Main.cpp:65:13: error: 'c' was not declared in this scope
   65 |             c = 0;
      |             ^
Main.cpp:67:17: error: 'assert' was not declared in this scope
   67 |                 assert(k <= n);
      |                 ^~~~~~
Main.cpp:67:17: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
Main.cpp:68:37: error: 'INF' was not declared in this scope
   68 |                 if (positions[k] == INF) {
      |                                     ^~~
Main.cpp:90:17: error: 'sum' was not declared in this scope
   90 |                 sum++;
      |                 ^~~
Main.cpp:98:5: error: 'cout' was not declared in this scope
   98 |     cout << sum << endl;
      |     ^~~~
Main.cpp:98:13: error: 'sum' was not declared in this scope
   98 |     cout << sum << endl;
      |             ^~~
Main.cpp:98:20: error: 'endl' was not declared in this scope
   98 |     cout << sum << endl;
      |                    ^~~~