Submission #1008021

#TimeUsernameProblemLanguageResultExecution timeMemory
1008021vjudge1Miners (IOI07_miners)C++17
45 / 100
1560 ms852 KiB
#include <bits/stdc++.h> using namespace std; int shipment2(char s1, char s2) { return 1 + (s1 != s2); } int shipment3(char s1, char s2, char s3) { if (s1 == s2 && s2 == s3) return 1; return (s1 != s2) + (s2 != s3) + (s3 != s1); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; string s; cin >> n >> s; int ans = 0; for (int mask = 0; mask < (1 << n)-1; mask++) { string mine1, mine2; for (int i = 0; i < n; i++) { if (mask & (1 << i)) mine1 += s[i]; else mine2 += s[i]; } int l1 = mine1.size(), l2 = mine2.size(); int sum = 0; if (l1 > 1) sum += 1 + shipment2(mine1[0], mine1[1]); else if (l1 == 1) sum += 1; if (l2 > 1) sum += 1 + shipment2(mine2[0], mine2[1]); else if (l2 == 1) sum += 1; for (int i = 2; i < l1; i++) { sum += shipment3(mine1[i], mine1[i-1], mine1[i-2]); } for (int i = 2; i < l2; i++) { sum += shipment3(mine2[i], mine2[i-1], mine2[i-2]); } ans = max(ans, sum); } cout << ans; }
#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...