# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
301285 | 2020-09-17T19:53:31 Z | joseacaz | 식물 비교 (IOI20_plants) | C++17 | 4000 ms | 62584 KB |
#include "plants.h" #include <bits/stdc++.h> #define pb push_back #define all(x) x.begin(), x.end() using namespace std; typedef long long ll; typedef vector<int> vi; const int MAXN = 2e5 + 5; int N, k, vis[MAXN], memo[5005][5005]; vi r, Graph[MAXN]; void sub(int idx) { for(int i = 1; i < k; i++) { int id = ((idx - i)%N + N)%N; if(r[id] > 0) { r[id]--; if(r[id] == 0 && !vis[id]) Graph[idx].pb(id); } } } int getnext(int idx) { for(int i = 1; i < N; i++) { int id = ((idx + i)%N + N)%N; if(i < k && !vis[id]) Graph[idx].pb(id); if(r[id] == 0 && !vis[id]) return id; } return idx; } void dfs(int root, int node) { if(memo[root][node]) return; memo[root][node] = 1; for(auto i : Graph[node]) if(i != node) dfs(root, i); } void init(int _k, vi _r) { k = _k; swap(r, _r); N = r.size(); int maxIdx = 0; for(int i = 0; i < N; i++) { if(r[i] != 0) continue; int maxim = 1; for(int j = 1; j < k; j++) { int id = ((i - j)%N + N)%N; if(r[id] == 0) maxim = 0; } if(maxim) maxIdx = i; } while(!vis[maxIdx]) { vis[maxIdx] = 1; sub(maxIdx); maxIdx = getnext(maxIdx); } for(int i = 0; i < N; i++) dfs(i, i); return; } int compare_plants(int x, int y) { if(memo[x][y]) return 1; else if(memo[y][x]) return -1; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 3 ms | 4992 KB | Output is correct |
5 | Correct | 3 ms | 5120 KB | Output is correct |
6 | Correct | 68 ms | 7932 KB | Output is correct |
7 | Runtime error | 260 ms | 62584 KB | Execution killed with signal 11 |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 4 ms | 4992 KB | Output is correct |
4 | Correct | 3 ms | 4992 KB | Output is correct |
5 | Correct | 6 ms | 5504 KB | Output is correct |
6 | Correct | 236 ms | 14452 KB | Output is correct |
7 | Execution timed out | 4021 ms | 52728 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 4 ms | 4992 KB | Output is correct |
4 | Correct | 3 ms | 4992 KB | Output is correct |
5 | Correct | 6 ms | 5504 KB | Output is correct |
6 | Correct | 236 ms | 14452 KB | Output is correct |
7 | Execution timed out | 4021 ms | 52728 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 5120 KB | Output is correct |
3 | Incorrect | 129 ms | 28280 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 3 ms | 4992 KB | Output is correct |
5 | Correct | 5 ms | 5120 KB | Output is correct |
6 | Incorrect | 6 ms | 5504 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 4 ms | 5248 KB | Output is correct |
5 | Incorrect | 43 ms | 12920 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 3 ms | 4992 KB | Output is correct |
5 | Correct | 3 ms | 5120 KB | Output is correct |
6 | Correct | 68 ms | 7932 KB | Output is correct |
7 | Runtime error | 260 ms | 62584 KB | Execution killed with signal 11 |
8 | Halted | 0 ms | 0 KB | - |