QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#618798#7757. Palm IslandshengZzzWA 1ms3824kbC++201.2kb2024-10-07 10:25:142024-10-07 10:25:15

Judging History

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

  • [2024-10-07 10:25:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3824kb
  • [2024-10-07 10:25:14]
  • 提交

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);
	if(a==b){
		cout<<endl;
	}
	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;
		}
	}
	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;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3824kb

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)