QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#666941 | #7757. Palm Island | miku | WA | 1ms | 5856kb | C++20 | 1.4kb | 2024-10-22 20:29:18 | 2024-10-22 20:29:25 |
Judging History
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;
map<pii,int>mpx;
for(int i=1;i<=n;i++){
cin>>a[i];
}
int idx=0;deque<ll>dq;
for(int i=1;i<=n;i++){
cin>>b[i];
mp[b[i]]=++idx;
}
for(int i=1;i<=n;i++){
a[i]=mp[a[i]];dq.pb(a[i]);
}
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
if(a[i]>b[j])mpx[{a[i],a[j]}]=1;
}
}
for(int i=1;i<=n*(n-1)/2;i++){
if(mpx[{dq[0],dq[1]}]){
mpx[{dq[0],dq[1]}]=0;
dq.pb(dq[1]);dq.pb(dq[0]);
dq.pop_front();cout<<2;
}
else dq.pb(dq[0]);
cout<<1;
dq.pop_front();
}
if(dq[0]!=1){
int w=n-dq[0]+1;
while(w--)cout<<1;
}
cout<<endl;
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);
int _=1;
cin>>_;
while(_--)solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5856kb
input:
2 3 1 2 3 2 3 1 4 1 2 3 4 2 1 3 4
output:
1111 21111111
result:
ok Correct. (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 5644kb
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:
121211 111111111 211111111 1112111111111 11111111111111 2111111111 211111 21111111 11211211 1211 1111 211111111 121111 11111 112111212121211 111111 112112111 1111 12111111 112111112111 1121121111 21111211111 1121121111 21111211 111111111111 1111 12121112111111 12111211111111 1121121111 1212111211121...
result:
wrong answer On Case#2: After your operations, a[1] = 4 but a[1] = 2. (test case 2)