Submission #831796

#TimeUsernameProblemLanguageResultExecution timeMemory
831796KerimMiners (IOI07_miners)C++17
45 / 100
1566 ms852 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 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 (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...