# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1104721 | 2024-10-24T09:23:59 Z | ezzzay | Board (CEOI13_board) | C++14 | 200 ms | 262144 KB |
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define int long long #define pb push_back map<vector<int>,int >dist; string a,b; vector<int> has (vector<int> v){ int n=v.size(); for(int i=n-1;i>=0;i--){ if(v[i]){ v[i]=0; for(int j=i+1;j<n;j++){ v[j]=1; } break; } } return v; } vector<int> nem (vector<int> v){ int n=v.size(); bool u=1; for(int i=n-1;i>=0;i--){ if(v[i]==0){ v[i]=1; u=0; for(int j=i+1;j<n;j++){ v[j]=0; } break; } } if(u){ v.clear(); v.pb(1); for(int i=0;i<n;i++){ v.pb(0); } } return v; } int fun(vector<int>a, vector<int>b){ if(a.size()!=b.size()){ if(max(a.size(),b.size())>20)return 1e8; } reverse(a.begin(),a.end()); reverse(b.begin(),b.end()); int x=0; for(int i=0;i<a.size();i++){ if(a[i]){ x+=(1<<i); } } int y=0; for(int i=0;i<b.size();i++){ if(b[i]){ y+=(1<<i); } } return abs(x-y); } signed main(){ cin>>a; vector<int>x={1},y={1}; int lvl=1; dist[{1}]=1; for(auto c:a){ if(c=='1'){ x.pb(0); lvl++; } else if(c=='2'){ x.pb(1); lvl++; } else if(c=='U'){ x.pop_back(); lvl--; } else if(c=='L'){ x=has(x); } else{ x=nem(x); } dist[x]=lvl; } lvl=1; cin>>a; for(auto c:a){ if(c=='1'){ y.pb(0); lvl++; } else if(c=='2'){ y.pb(1); lvl++; } else if(c=='U'){ y.pop_back(); lvl--; } else if(c=='L'){ has(y); } else{ nem(y); } dist[y]=lvl; } if(dist[y]>dist[x]){ swap(y,x); } int k=0; int p=dist[x]; while(dist[x]>dist[y]){ x.pop_back(); dist[x]= --p; k++; } int ans=k+fun(x,y); p=dist[x]; while(p>1){ x.pop_back(); y.pop_back(); p--; k+=2; ans=min(ans,k+fun(x,y)); } cout<<ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 17 ms | 848 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Incorrect | 1 ms | 336 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 1632 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 760 KB | Output is correct |
2 | Incorrect | 1 ms | 592 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 118 ms | 9032 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 547 ms | 63456 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 616 ms | 262144 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 621 ms | 262144 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 619 ms | 262144 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |