Submission #1066891

#TimeUsernameProblemLanguageResultExecution timeMemory
1066891KasymKMiners (IOI07_miners)C++17
100 / 100
73 ms1112 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> #define wr puts("----------------") template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} int dp[2][4][4][4][4]; int main(){ int n; scanf("%d", &n); int a[n]; string s; cin >> s; for(int i = 0; i < n; ++i){ if(s[i] == 'M') a[i] = 1; else if(s[i] == 'B') a[i] = 2; else a[i] = 3; } for(int x = n-1; x >= 0; --x) for(int a1 = 0; a1 <= 3; ++a1) for(int a2 = 0; a2 <= 3; ++a2) for(int b1 = 0; b1 <= 3; ++b1) for(int b2 = 0; b2 <= 3; ++b2){ int o = 0, o1 = 0, o2 = 0; o = (a1 == 1 or a2 == 1 or a[x] == 1 ? 1 : 0); o1 = (a1 == 2 or a2 == 2 or a[x] == 2 ? 1 : 0); o2 = (a1 == 3 or a2 == 3 or a[x] == 3 ? 1 : 0); int m1 = o+o1+o2; o = 0, o1 = 0, o2 = 0; o = (b1 == 1 or b2 == 1 or a[x] == 1 ? 1 : 0); o1 = (b1 == 2 or b2 == 2 or a[x] == 2 ? 1 : 0); o2 = (b1 == 3 or b2 == 3 or a[x] == 3 ? 1 : 0); int m2 = o+o1+o2; dp[x&1][a1][a2][b1][b2] = max(dp[(x+1)&1][a[x]][a1][b1][b2]+m1, dp[(x+1)&1][a1][a2][a[x]][b1]+m2); } int answer = dp[0][0][0][0][0]; printf("%d\n", answer); return 0; }

Compilation message (stderr)

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