QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#618771 | #7757. Palm Island | lixp | TL | 1ms | 3812kb | C++14 | 1.2kb | 2024-10-07 10:04:07 | 2024-10-07 10:04:08 |
Judging History
answer
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 2e5 + 9;
ll inf = 9223372036854775807;
void shift1(string &s){
string a=s.substr(1,s.length()-1);
char b=s[0];
s=a+b;
}
void shift2(string &s){
string a=s.substr(2,s.length()-1);
char b=s[0];
char c=s[1];
s=b+a+c;
}
void solve() {
int n;
cin>>n;
string a="a";
string b="a";
string ans="a";
for(int i=0;i<n;i++){
string c;
cin>>c;
a=a+c;
}
for(int i=0;i<n;i++){
string c;
cin>>c;
b=b+c;
}
a=a.substr(1,n);
b=b.substr(1,n);
int flag=0;
int i=0;
while(a!=b){
if(b[i]!=a[flag] && flag==0){
shift1(a);
ans=ans+"1";
}
else if(b[i]!=a[flag] && flag==1){
shift2(a);
ans=ans+"2";
}
if(b[i]==a[flag]){
flag=1-flag;
i=(i+1)%n;
}
}
if(ans==" "){
cout<<endl;
return;
}
ans=ans.substr(1,sizeof(ans)-1);
cout<<ans<<endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3644kb
input:
2 3 1 2 3 2 3 1 4 1 2 3 4 2 1 3 4
output:
1 122
result:
ok Correct. (2 test cases)
Test #2:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
200 3 3 1 2 2 3 1 4 2 4 1 3 2 1 4 3 4 1 4 2 3 2 1 3 4 5 4 3 2 1 5 2 4 5 3 1 5 2 1 5 4 3 5 2 4 1 3 4 4 3 1 2 1 2 4 3 3 1 2 3 3 1 2 4 1 4 2 3 2 1 4 3 4 1 3 2 4 1 4 3 2 3 3 2 1 1 3 2 3 2 3 1 1 3 2 4 1 4 3 2 3 1 2 4 3 1 2 3 1 3 2 3 3 2 1 2 3 1 5 5 1 3 2 4 2 4 5 1 3 4 4 3 1 2 1 4 3 2 4 1 3 4 2 2 4 3 1 3 ...
output:
11 21112211 1121112211 1122111122111 1122111222111 11 11 112 22 11 112 1121112211 2 12 111 112 111221112211 1 111221111111221 11122 11221112211 11121112211 121112211 111221121111221 1 2111222111 111111111221 11122 2 2 111221112211 12 11221111111221 11112211112221111221 112221121111221 12 1121112211...
result:
ok Correct. (200 test cases)
Test #3:
score: 0
Accepted
time: 1ms
memory: 3564kb
input:
200 5 5 1 3 4 2 5 3 2 4 1 5 5 1 2 4 3 3 5 4 1 2 5 1 4 5 3 2 2 5 4 3 1 5 1 5 4 3 2 4 5 2 3 1 5 2 3 4 5 1 5 4 3 2 1 5 1 5 2 4 3 5 3 1 2 4 5 1 2 4 3 5 4 2 3 5 1 5 3 2 1 4 5 4 2 3 1 5 5 3 1 2 5 4 2 4 1 3 5 5 5 3 1 4 2 2 5 4 1 3 5 5 4 3 1 2 2 5 4 1 3 5 3 4 5 2 1 3 5 1 4 2 5 4 5 1 3 2 4 2 3 1 5 5 1 3 4 5 ...
output:
2111222111 1111111122111 111122111122111 11222111222111 11122211112221111221 122 11222 11122111122111 112111222111 111111112221111221 11111121111221 21111111221 22211112221111221 1122211112221111221 22111122111 11122 122 2221121111221 1122211112221111221 1121111111221 22111222111 222 111122111 1121...
result:
ok Correct. (200 test cases)
Test #4:
score: -100
Time Limit Exceeded
input:
100 5 1 2 5 4 3 2 4 5 3 1 6 6 1 5 2 4 3 1 4 5 6 2 3 3 2 1 3 1 2 3 5 5 3 4 2 1 1 2 3 5 4 10 5 9 4 2 6 10 7 8 3 1 1 3 4 10 5 7 2 9 8 6 10 5 9 10 7 8 3 4 6 2 1 2 7 4 3 10 9 5 8 1 6 8 1 7 4 6 3 5 2 8 3 5 1 4 6 8 7 2 4 2 3 4 1 1 4 2 3 7 3 7 4 6 2 1 5 5 6 7 3 4 1 2 8 2 1 4 7 8 3 6 5 5 2 7 4 3 1 8 6 4 3 2 ...
output:
12111122111