Submission #831797

#TimeUsernameProblemLanguageResultExecution timeMemory
831797KerimMiners (IOI07_miners)C++17
45 / 100
1573 ms724 KiB
#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 bit[] = {0, 1, 1, 2, 1, 2, 2, 3}; int f(int x, int y, int z){ int mask = 0; if (x) mask |= (1<<(x-1)); if (y) mask |= (1<<(y-1)); if (z) mask |= (1<<(z-1)); return bit[mask]; } 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 (stderr)

miners.cpp: In function 'int main()':
miners.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
miners.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     scanf("%s", s);
      |     ~~~~~^~~~~~~~~
#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...
#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...