Submission #257039

#TimeUsernameProblemLanguageResultExecution timeMemory
257039dooweyBoard (CEOI13_board)C++14
10 / 100
1096 ms1288 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; } int main(){ fastIO; string a, b; cin >> a >> b; vector<int> p = gen(a), q = gen(b); int ans = 0; int cq; for(int t = 0; t < min(p.size(),q.size()); t ++ ){ if(p[t] != q[t]){ cq = t + 1; while(cq < p.size()){ if(p[cq] != p[t]) cq ++ ; else break; } while(p.size() > cq){ ans ++ ; p.pop_back(); } ans ++ ; for(int j = t; j < cq; j ++ ){ p[j] ^= 1; } } } ans += abs((int)q.size() - (int)p.size()); cout << ans << "\n"; return 0; }

Compilation message (stderr)

board.cpp: In function 'int main()':
board.cpp:58:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int t = 0; t < min(p.size(),q.size()); t ++ ){
                    ~~^~~~~~~~~~~~~~~~~~~~~~~~
board.cpp:61:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while(cq < p.size()){
                   ~~~^~~~~~~~~~
board.cpp:65:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while(p.size() > cq){
                   ~~~~~~~~~^~~~
#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...