Submission #393010

#TimeUsernameProblemLanguageResultExecution timeMemory
393010phathnvComparing Plants (IOI20_plants)C++11
11 / 100
4091 ms2097156 KiB
#include <bits/stdc++.h> #include "plants.h" using namespace std; vector<vector<bool>> d; void init(int k, std::vector<int> r) { int n = r.size(); vector<int> p(n, -1); d.assign(n, vector<bool>(n, 0)); for(int val = n - 1; val >= 0; val--){ for(int i = 0; i < n; i++){ if (r[i] || r[i] == -1) continue; bool ok = 1; for(int j = 1; j < k; j++) ok &= (r[(i - j + n) % n] != 0); if (ok){ p[i] = val; for(int j = 1; j < k; j++){ if (r[(i - j + n) % n] != -1){ r[(i - j + n) % n]--; d[i][(i - j + n) % n] = 1; } if (r[(i + j) % n] != -1) d[i][(i + j) % n] = 1; } r[i] = -1; break; } } } for(int k = 0; k < n; k++) for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) d[i][j] = d[i][j] || (d[i][k] && d[k][j]); return; } int compare_plants(int x, int y) { if (d[x][y]) return 1; if (d[y][x]) return -1; return 0; }

Compilation message (stderr)

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:35:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   35 |     for(int k = 0; k < n; k++)
      |     ^~~
plants.cpp:40:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   40 |  return;
      |  ^~~~~~
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:46:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   46 |     if (d[y][x])
      |     ^~
plants.cpp:48:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   48 |  return 0;
      |  ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...