# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
80453 | 2018-10-20T21:47:58 Z | Plurm | 게임판 (CEOI13_board) | C++11 | 200 ms | 1284 KB |
#include <bits/stdc++.h> using namespace std; char a[100005]; char b[100005]; class holder : public vector<bool> { public: vector<int> hsh; inline int ghash(){ return size() <= 20 ? size() : hsh[size()-21]; } inline int to_int(){ int v = 0; for(int i = max((int)size()-20,0); i < size(); i++){ v *= 2; if(at(i)) v++; } return v; } void push_back(bool b){ vector<bool>::push_back(b); if(hsh.empty()) hsh.push_back(b ? 1 : 0); else hsh.push_back(53*hsh.back() + (b ? 1 : 0)); } void pop_back(){ vector<bool>::pop_back(); hsh.pop_back(); } }; inline void mmove(holder& x,char y){ int i; switch(y){ case '1': x.push_back(false); break; case '2': x.push_back(true); break; case 'U': x.pop_back(); break; case 'L': for(i = x.size()-1; i >= 0; i--){ if(x[i]){ x[i] = false; break; }else{ x[i] = true; } } for(; i < x.size(); i++){ if(i == 0) x.hsh[i] = x[i] ? 1 : 0; else x.hsh[i] = x.hsh[i-1]*53 + (x[i] ? 1 : 0); } break; case 'R': for(i = x.size()-1; i >= 0; i--){ if(x[i]){ x[i] = false; }else{ x[i] = true; break; } } for(; i < x.size(); i++){ if(i == 0) x.hsh[i] = x[i] ? 1 : 0; else x.hsh[i] = x.hsh[i-1]*53 + (x[i] ? 1 : 0); } break; } } pair<int,int> mem[100005]; int main(){ gets(a); gets(b); if(strlen(a) < strlen(b)){ for(int i = 0; i < 100005; i++){ swap(a[i],b[i]); } } holder ma; holder mb; for(int i = 0; a[i]; i++){ mmove(ma,a[i]); } int lla = ma.size(); while(!ma.empty()){ mem[ma.size()] = make_pair(ma.ghash(),ma.to_int()); ma.pop_back(); } for(int i = 0; b[i]; i++){ mmove(mb,b[i]); } int llb = mb.size(); int d = 1e9; while(!mb.empty()){ if(mb.ghash() == mem[mb.size()].first){ d = min(d,(int)(lla - mb.size() + llb - mb.size() + abs(mb.to_int() - mem[mb.size()].second))); } mb.pop_back(); } printf("%d\n",d); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 504 KB | Output is correct |
3 | Correct | 2 ms | 504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 536 KB | Output is correct |
2 | Correct | 3 ms | 536 KB | Output is correct |
3 | Correct | 5 ms | 668 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 668 KB | Output is correct |
2 | Correct | 2 ms | 668 KB | Output is correct |
3 | Correct | 2 ms | 668 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 688 KB | Output is correct |
2 | Correct | 7 ms | 688 KB | Output is correct |
3 | Correct | 5 ms | 688 KB | Output is correct |
4 | Correct | 2 ms | 688 KB | Output is correct |
5 | Correct | 2 ms | 688 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 756 KB | Output is correct |
2 | Correct | 3 ms | 756 KB | Output is correct |
3 | Incorrect | 2 ms | 756 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 756 KB | Output is correct |
2 | Correct | 3 ms | 760 KB | Output is correct |
3 | Incorrect | 3 ms | 760 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 760 KB | Output is correct |
2 | Correct | 7 ms | 772 KB | Output is correct |
3 | Correct | 5 ms | 772 KB | Output is correct |
4 | Incorrect | 2 ms | 772 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1071 ms | 1068 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1080 ms | 1164 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1086 ms | 1284 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |