# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
730054 | 2023-04-25T07:57:50 Z | lovrot | Olympiads (BOI19_olympiads) | C++17 | 76 ms | 4648 KB |
#include <cstdio> #include <queue> #define pb push_back using namespace std; typedef pair<int, int> pii; const int N = 500; const int K = 6; int n, k, event[N][K]; //perm; -1 => ban | 0 => whatever | 1 => must struct space { char perm[N], cnt; int best[K], score; space() { for(int i = 0; i < N; i++) perm[i] = 0; for(int i = 0; i < K; i++) best[i] = -1; cnt = score = 0; } void evaluate() { for(int i = 0; i < n; i++) if(perm[i] == 1) { best[cnt] = i; cnt++; } for(int i = cnt; i < k; i++) { best[i] = -1; for(int j = 0; j < n; j++) { bool flag = true; for(int l = 0; l < i; l++) flag &= j != best[l]; if(flag && perm[j] == 0 && (best[i] == -1 || event[best[i]][i] < event[j][i])) best[i] = j; } } for(int i = 0; i < k; i++) { //printf("/ best %d\n", best[i]); int xam = 0; for(int j = 0; j < k; j++) xam = max(xam, event[best[j]][i]); score += xam; } //printf("/ score %d\n", score); } bool operator< (space s) const { return score < s.score; } }; priority_queue<space> q; void debug(const space &s) { for(int i = 0; i < n; i++) printf("%d ", s.perm[i]); printf("\n"); for(int i = 0; i < k; i++) printf("%d ", s.best[i]); printf("\n%d %d\n", s.score, s.cnt); } void fracture(space &s) { for(int i = 0; i < s.cnt; i++) s.perm[s.best[i]] = 1; for(int i = s.cnt; i < k; i++) { s.perm[s.best[i]] = -1; space _s = space(); for(int j = 0; j < n; j++) _s.perm[j] = s.perm[j]; _s.evaluate(); if(_s.best[k - 1] != -1) { q.push(_s); //debug(_s); } s.perm[s.best[i]] = 1; } } int t; int main() { scanf("%d%d%d", &n, &k, &t); for(int i = 0; i < n; i++) for(int j = 0; j < k; j++) scanf("%d", &event[i][j]); space s = space(); s.evaluate(); q.push(s); int cnt = 0; while(1) { cnt++; space _s = q.top(); q.pop(); //debug(s); if(cnt == t) { printf("%d\n", _s.score); break; } fracture(_s); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 300 KB | Output is correct |
2 | Correct | 6 ms | 364 KB | Output is correct |
3 | Correct | 7 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 296 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 1440 KB | Output is correct |
2 | Correct | 4 ms | 676 KB | Output is correct |
3 | Correct | 9 ms | 2596 KB | Output is correct |
4 | Correct | 6 ms | 1420 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 340 KB | Output is correct |
2 | Correct | 7 ms | 292 KB | Output is correct |
3 | Correct | 37 ms | 2440 KB | Output is correct |
4 | Correct | 40 ms | 2508 KB | Output is correct |
5 | Correct | 15 ms | 924 KB | Output is correct |
6 | Correct | 5 ms | 1420 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 300 KB | Output is correct |
2 | Correct | 6 ms | 364 KB | Output is correct |
3 | Correct | 7 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 296 KB | Output is correct |
5 | Correct | 7 ms | 1440 KB | Output is correct |
6 | Correct | 4 ms | 676 KB | Output is correct |
7 | Correct | 9 ms | 2596 KB | Output is correct |
8 | Correct | 6 ms | 1420 KB | Output is correct |
9 | Correct | 8 ms | 340 KB | Output is correct |
10 | Correct | 7 ms | 292 KB | Output is correct |
11 | Correct | 37 ms | 2440 KB | Output is correct |
12 | Correct | 40 ms | 2508 KB | Output is correct |
13 | Correct | 15 ms | 924 KB | Output is correct |
14 | Correct | 5 ms | 1420 KB | Output is correct |
15 | Correct | 12 ms | 968 KB | Output is correct |
16 | Correct | 28 ms | 2524 KB | Output is correct |
17 | Correct | 76 ms | 4648 KB | Output is correct |
18 | Correct | 27 ms | 1524 KB | Output is correct |
19 | Correct | 7 ms | 356 KB | Output is correct |