QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#666865#7757. Palm IslandmikuWA 1ms5528kbC++201.3kb2024-10-22 20:14:502024-10-22 20:14:58

Judging History

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

  • [2024-10-22 20:14:58]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5528kb
  • [2024-10-22 20:14:50]
  • 提交

answer

#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define endl '\n'
using namespace std;
using ll =long long ;
using pii =pair<int,int>;
using pll=pair<ll,ll>;
bool cmp(pll a,pll b){
	return a.y<b.y;
}
struct cmp1{
    bool operator()(pair<ll,ll>a,pair<ll,ll>b){
	if(a.x==b.x)return a.y>b.y;
	return a.x>b.x; 
}
};
const int mod=998244353;
ll ksm(ll a,ll b){ll ans=1;while(b){if(b&1){ans*=a;ans=ans%mod;}a=a*a;a%=mod;b>>=1;}return ans;}
ll gcd(ll a,ll b){ll t=a%b;while(t){a=b;b=t;t=a%b;}return b;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll get_inv(ll x){return ksm(x,mod-2);}
const int N=5e5+10;
ll a[N];
ll b[N];
void solve(){
	int n;
	cin>>n;
	map<int,int>mp;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int idx=0;
	for(int i=1;i<=n;i++){
		cin>>b[i];
		mp[b[i]]=++idx;
	}deque<ll>dq;
	for(int i=1;i<=n;i++){
		a[i]=mp[a[i]];
		dq.pb(a[i]);
	}
	vector<int>v;
	for(int i=1;i<=n*(n-1)/2;i++){
		if(dq[0]<dq[1]){
			v.pb(1);v.pb(2);dq.pb(dq[0]);dq.pb(dq[1]);
		}
		else{
			v.pb(2);v.pb(1);dq.pb(dq[1]);dq.pb(dq[0]);
		}
		dq.pop_front();dq.pop_front();
	}
	if(dq[0]!=1){
		int w=n-dq[0]+1;
		while(w--)v.pb(1);
	}
	for(auto c:v)cout<<c;cout<<endl;
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	int _=1;
	cin>>_;
	while(_--)solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

21212111
211212121212

result:

wrong answer On Case#1: After your operations, a[1] = 1 but a[1] = 2. (test case 1)