QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#293866 | #4831. Eager Sorting | ucup-team266# | 0 | 1ms | 3780kb | C++20 | 1.7kb | 2023-12-29 21:15:33 | 2023-12-29 21:15:33 |
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
mt19937 rnd(318932321);
int p[105],pos[105];
void sw(int a,int b)
{
swap(p[pos[a]],p[pos[b]]);
swap(pos[a],pos[b]);
}
vector<int> solve(vector<int> cur)
{
if(sz(cur)<=1) return cur;
int p=rnd()%sz(cur);
vector<int> v1,v2;
for(int i=0;i<sz(cur);i++)
if(i!=p)
{
cout<<pos[cur[i]]<<" "<<pos[cur[p]]<<endl;
int x;
cin>>x;
if(x==-1) exit(0);
if((pos[cur[i]]<pos[cur[p]])^x)
v2.pb(cur[i]);
else
v1.pb(cur[i]);
if(x) sw(cur[i],cur[p]);
}
vector<int> ret=solve(v1);
ret.pb(cur[p]);
vector<int> tmp=solve(v2);
for(auto x:tmp)
ret.pb(x);
return ret;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
for(int i=1;i<=n;i++)
p[i]=pos[i]=i;
vector<int> vec;
for(int i=1;i<=n;i++)
vec.pb(i);
vec=solve(vec);
for(int i=0;i<n;i++)
if(pos[vec[i]]!=i+1)
{
cout<<i+1<<" "<<pos[vec[i]]<<endl;
int x;
cin>>x;
if(x==-1) exit(0);
if(x) sw(i+1,pos[vec[i]]);
}
cout<<"-1 -1"<<endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3556kb
Interactor to First Run
5 0 1 1 0 1 1 0 0 -1
First Run to Interactor
1 5 2 5 3 2 4 3 4 5 1 2 1 5 2 4 4 2
Interactor to Second Run
5 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Second Run to Interactor
1 5 2 5 3 5 4 5 2 1 3 1 4 1 3 2 4 2 3 4 1 5 2 4 4 2 5 1 -1 -1
Manager to Checker
OK good job!
result:
ok OK
Test #2:
score: 100
Accepted
time: 1ms
memory: 3776kb
Interactor to First Run
1
First Run to Interactor
-1 -1
Interactor to Second Run
1
Second Run to Interactor
-1 -1
Manager to Checker
OK good job!
result:
ok OK
Test #3:
score: 100
Accepted
time: 1ms
memory: 3780kb
Interactor to First Run
2 0 0 0
First Run to Interactor
1 2 1 2 2 1 -1 -1
Interactor to Second Run
2 0 0 0
Second Run to Interactor
1 2 1 2 2 1 -1 -1
Manager to Checker
OK good job!
result:
ok OK
Test #4:
score: 100
Accepted
time: 1ms
memory: 3556kb
Interactor to First Run
2 1 0 0
First Run to Interactor
1 2 1 2 2 1 -1 -1
Interactor to Second Run
2 0 -1
Second Run to Interactor
1 2 1 2
Manager to Checker
OK good job!
result:
ok OK
Test #5:
score: 100
Accepted
time: 1ms
memory: 3624kb
Interactor to First Run
9 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 1 1 0 1 0 1 1 0 0 0 0 1 0 0 0 0
First Run to Interactor
1 7 2 7 3 7 4 7 5 7 6 7 8 7 9 8 1 5 2 5 3 5 4 5 6 4 7 6 8 6 7 5 8 7 5 7 2 1 3 2 4 2 2 1 1 9 2 8 3 7 4 5 5 6 6 3 7 4 8 2 9 6 -1 -1
Interactor to Second Run
9 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Second Run to Interactor
1 7 2 7 3 7 4 7 5 7 6 7 8 7 9 7 9 8 1 4 2 4 3 4 5 3 6 3 5 4 6 4 6 5 2 1 1 9 2 8 3 7 4 6 6 4 7 3 8 2 9 1 -1 -1
Manager to Checker
OK good job!
result:
ok OK
Test #6:
score: 0
Wrong Answer
time: 1ms
memory: 3584kb
Interactor to First Run
9 0 1 1 1 1 1 0 1 0 1 1 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0
First Run to Interactor
1 7 2 7 3 2 4 3 5 4 6 5 8 6 9 6 8 7 1 4 2 1 3 2 5 3 6 3 5 4 6 4 6 5 2 1 1 8 2 7 3 9 4 6 6 4 7 3 8 2 9 1 -1 -1
Interactor to Second Run
9 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Second Run to Interactor
1 7 2 7 3 7 4 7 5 7 6 7 8 7 9 7 1 6 2 6 3 6 4 6 5 6 7 6 2 1 3 1 4 1 5 1 2 5 3 5 4 5 2 4 3 4 3 2 1 8 2 9 3 7 4 6 6 4 7 3 8 2 9 1 -1 -1
Manager to Checker
WA array is not sorted!
result:
wrong answer WA