# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
401250 | 2021-05-09T16:59:39 Z | my99n | Comparing Plants (IOI20_plants) | C++14 | 4000 ms | 336 KB |
#include "plants.h" #include <bits/stdc++.h> using namespace std; int n; int ans[5010]; int in[5010]; vector<int> g[5010]; vector<int> r; int dis (int i, int j) { if (i == -1e9 or j == -1e9) return -1e9; return (j-i+n) % n; } void init(int k, vector<int> R) { r = R; n = r.size(); int cnt = 0; while (cnt < n) { queue<int> c; for (int i = 0; i < n; i++) { if (r[i] == 0) { for (int j = 1; j < k; j++) { int ind = (i+j+n)%n; if (r[ind] == -1) continue; g[ind].push_back(i); // cerr << ind << " -> " << i << endl; in[i]++; } c.push(i); // cerr << "out " << i << endl; r[i] = -1; cnt++; } } while (!c.empty()) { auto t = c.front(); c.pop(); for (int i = 1; i < k; i++) { int ind = (t-i+n) % n; // cerr << "- " << ind << endl; if (r[ind] != -1) { g[ind].push_back(t); in[t]++; // cerr << ind << " -> " << t << endl; r[ind]--; } } } } queue<pair<int,int>> q; for (int i = 0; i < n; i++) { if (in[i] == 0) q.push({i, 0}); // smallest } while (!q.empty()) { auto [t, l] = q.front(); q.pop(); ans[t] = l; for (auto x : g[t]) { in[x]--; if (!in[x]) q.push({x, l+1}); } } return; } int compare_plants(int x, int y) { if (ans[x] < ans[y]) return -1; if (ans[x] > ans[y]) return 1; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Incorrect | 1 ms | 332 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Incorrect | 1 ms | 332 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Incorrect | 1 ms | 332 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Execution timed out | 4062 ms | 332 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Incorrect | 1 ms | 332 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Execution timed out | 4062 ms | 332 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Incorrect | 1 ms | 332 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |