Submission #257050

#TimeUsernameProblemLanguageResultExecution timeMemory
257050dooweyBoard (CEOI13_board)C++14
40 / 100
1092 ms2940 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); vector<int> gen(string t){ vector<int> res = {1}; for(char x : t){ if(x == '1') res.push_back(0); else if(x == '2') res.push_back(1); else if(x == 'U'){ res.pop_back(); } else if(x == 'L'){ int id = res.size() - 1; while(id >= 0){ if(res[id] == 0){ res[id] ^= 1; } else{ res[id] ^= 1; break; } id -- ; } } else{ int id = res.size() - 1; while(id >= 0){ if(res[id] == 0){ res[id] ^= 1; break; } else{ res[id] ^= 1; } id -- ; } } } return res; } const ll MX = (int)1e9 + 7; const int N = (int)2e5 + 10; ll pw[N]; int main(){ fastIO; pw[0]=1; for(int i = 1; i < N; i ++ ) pw[i]=min(MX,pw[i-1]*2ll); string a, b; cin >> a >> b; vector<int> p = gen(a), q = gen(b); if(p.size() > q.size()) swap(p,q); ll low = (int)p.size() - 1 + (int)q.size() - 1; ll dif; for(int com = 1; com <= min(p.size(), q.size()); com ++ ){ dif = 0; int who = -1; for(int i = 0 ; i < com; i ++ ){ if(p[i] != q[i]){ if(who == -1){ if(p[i] == 1) who = 0; else who = 1; } if(who == 0){ if(p[i] == 1){ dif = min(dif + pw[com - i - 1], MX); if(dif == MX) break; } else{ dif -= pw[com - i - 1]; } } else{ if(q[i] == 1){ dif = min(dif + pw[com - i - 1], MX); if(dif == MX) break; } else{ dif -= pw[com - i - 1]; } } } } low = min(low, dif + (ll)p.size() - com + (ll)q.size() - com); } cout << low << "\n"; return 0; }

Compilation message (stderr)

board.cpp: In function 'int main()':
board.cpp:67:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int com = 1; com <= min(p.size(), q.size()); com ++ ){
                      ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...