Submission #211793

#TimeUsernameProblemLanguageResultExecution timeMemory
211793sochoMiners (IOI07_miners)C++14
45 / 100
1591 ms1100 KiB
#include "bits/stdc++.h" using namespace std; // #define endl '\n' // #define int long long int diff(int a, int b, int c) { if (a == b && b == c) return 1; if (a == b || b == c || a == c) return 2; return 3; } signed main() { int n; cin >> n; string s; cin >> s; int best = 0; for (int i=0; i<(1<<n); i++) { deque<int> le, ri; int here = 0; for (int j=0; j<n; j++) { if ((1 << j) & i) le.push_back(s[j]); else ri.push_back(s[j]); } for (int i=0; i<le.size(); i++) { if (i == 0) here++; else if (i == 1) { if (le[0] == le[1]) here++; else here += 2; } else { here += diff(le[i-2], le[i-1], le[i]); } } for (int i=0; i<ri.size(); i++) { if (i == 0) here++; else if (i == 1) { if (ri[0] == ri[1]) here++; else here += 2; } else { here += diff(ri[i-2], ri[i-1], ri[i]); } } best = max(best, here); } cout << best << endl; }

Compilation message (stderr)

miners.cpp: In function 'int main()':
miners.cpp:30:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=0; i<le.size(); i++) {
                 ~^~~~~~~~~~
miners.cpp:41:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=0; i<ri.size(); i++) {
                 ~^~~~~~~~~~
#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...