Submission #919744

#TimeUsernameProblemLanguageResultExecution timeMemory
919744penguin133Miners (IOI07_miners)C++17
100 / 100
172 ms113648 KiB
#include <bits/stdc++.h> using namespace std; //#define int long long #define pi pair<int, int> #define pii pair<int, pi> #define fi first #define se second #ifdef _WIN32 #define getchar_unlocked _getchar_nolock #endif mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int memo[100005][4][4][4][4], n; int A[100005]; int dp(int x, int ls, int ls2, int pr, int pr2){ if(x == n + 1)return 0; if(memo[x][ls][ls2][pr][pr2] != -1)return memo[x][ls][ls2][pr][pr2]; int tmp = 0; if(ls == 1 || ls2 == 1 || A[x] == 1)tmp++; if(ls == 2 || ls2 == 2 || A[x] == 2)tmp++; if(ls == 3 || ls2 == 3 || A[x] == 3)tmp++; tmp += dp(x + 1, A[x], ls, pr, pr2); int tmp2 = 0; if(pr == 1 || pr2 == 1 || A[x] == 1)tmp2++; if(pr == 2 || pr2 == 2 || A[x] == 2)tmp2++; if(pr == 3 || pr2 == 3 || A[x] == 3)tmp2++; tmp2 += dp(x + 1, ls, ls2, A[x], pr); return memo[x][ls][ls2][pr][pr2] = max(tmp, tmp2); } void solve(){ cin >> n; for(int i = 1; i <= n; i++){ char x; cin >> x; if(x == 'M')A[i] = 1; if(x == 'B')A[i] = 2; if(x == 'F')A[i] = 3; } memset(memo, -1, sizeof(memo)); cout << dp(1, 0, 0, 0, 0) << '\n'; } main(){ ios::sync_with_stdio(0);cin.tie(0); int tc = 1; //cin >> tc; for(int tc1=1;tc1<=tc;tc1++){ // cout << "Case #" << tc1 << ": "; solve(); } }

Compilation message (stderr)

miners.cpp:45:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   45 | main(){
      | ^~~~
#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...