Submission #1066714

#TimeUsernameProblemLanguageResultExecution timeMemory
1066714KasymKMiners (IOI07_miners)C++17
100 / 100
635 ms116820 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;} const int N = 1e5+5; int n; string s; int dp[N][4][4][4][4], a[N]; int val(vector<int> v){ set<int> s; for(int &i : v) if(i) s.insert(i); int ret = (int)s.size(); return ret; } int f(int x, int a1, int a2, int b1, int b2){ if(x == n) return 0; int &res = dp[x][a1][a2][b1][b2]; if(~res) return res; int m1,m2; m1 = val({a1, a2, a[x]}); m2 = val({b1, b2, a[x]}); return res = max(f(x+1, a[x], a1, b1, b2)+m1, f(x+1, a1, a2, a[x], b1)+m2); } int main(){ memset(dp, -1, sizeof dp); scanf("%d", &n); 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; } int answer = f(0, 0, 0, 0, 0); printf("%d\n", answer); return 0; }

Compilation message (stderr)

miners.cpp: In function 'int main()':
miners.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |     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...