QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#618785#7757. Palm IslandshengZzzWA 0ms3592kbC++201.2kb2024-10-07 10:18:152024-10-07 10:18:17

Judging History

你现在查看的是最新测评结果

  • [2024-10-07 10:18:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3592kb
  • [2024-10-07 10:18:15]
  • 提交

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;
	int cnt=0;
	while(a!=b){
		if(b[i]!=a[flag] && flag==0){
			shift1(a);
			ans=ans+"1";
			cout<<a<<endl;
		}
		else if(b[i]!=a[flag] && flag==1){
			shift2(a);
			ans=ans+"2";
			cout<<a<<endl;
		}
		if(b[i]==a[flag]){
			flag=1-flag;
			i=(i+1)%n;
		}
	}
	if(ans==" "){
		cout<<endl;
		return;
	} 
	ans=ans.substr(1,ans.length()-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: 0
Wrong Answer
time: 0ms
memory: 3592kb

input:

2
3
1 2 3
2 3 1
4
1 2 3 4
2 1 3 4

output:

231
1
2341
2413
2134
122

result:

wrong answer Line [name=s] equals to "231", doesn't correspond to pattern "[1-2]{0,1000000}" (test case 1)