# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
80397 | Plurm | 게임판 (CEOI13_board) | C++11 | 1088 ms | 1608 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 ? -1 : hsh[size()-21];
}
inline int to_int(){
int v = 1;
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)) % 1000003);
}
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)) % 1000003;
}
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)) % 1000003;
}
break;
}
}
inline int glv(int x){
int l = 0;
while(x > 1){
x /= 2;
l++;
}
return l;
}
pair<int,int> mem[100005];
int main(){
gets(a);
gets(b);
holder ma;
holder mb;
for(int i = 0; a[i]; i++){
mmove(ma,a[i]);
}
for(int i = 0; b[i]; i++){
mmove(mb,b[i]);
}
if(ma.size() < mb.size()){
for(int i = 0; i < 100005; i++){
swap(a[i],b[i]);
}
swap(ma,mb);
}
int lla = ma.size();
while(!ma.empty()){
mem[ma.size()] = make_pair(ma.ghash(),ma.to_int());
ma.pop_back();
}
int llb = mb.size();
int d = lla + llb;
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);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |