# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
831796 | 2023-08-20T15:11:44 Z | Kerim | Miners (IOI07_miners) | C++17 | 1500 ms | 852 KB |
#include "bits/stdc++.h" #define pb(x) push_back(x) using namespace std; const int N = 1e5+5; const int INF = 1e9+10; char s[N]; int a[2], b[2]; int arr[N]; int f(int x, int y, int z){ set<int> s; //TODO if (x) s.insert(x); if (y) s.insert(y); if (z) s.insert(z); return s.size(); } int main(){ // freopen("file.in", "r", stdin); // freopen("file.out", "w", stdout); int n; scanf("%d", &n); scanf("%s", s); for (int i = 0; i < n; i++){ if (s[i] == 'M') arr[i] = 1; else if(s[i] == 'F') arr[i] = 2; else arr[i] = 3; } int answer = 0; for (int mask = 0; mask < (1<<n); mask++){ a[0] = a[1] = 0; b[0] = b[1] = 0; int cost = 0; for (int i = 0; i < n; i++){ if (mask>>i&1){ cost += f(a[0], a[1], arr[i]); a[0] = a[1]; a[1] = arr[i]; } else{ cost += f(b[0], b[1], arr[i]); b[0] = b[1]; b[1] = arr[i]; } } answer = max(answer, cost); } printf("%d\n", answer); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 292 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 86 ms | 284 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 492 ms | 304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 821 ms | 308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1566 ms | 212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 14 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 57 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1554 ms | 340 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 344 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1563 ms | 724 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 852 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |