QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#589228 | #7535. Limited Shuffle Restoring | Kevin5307 | WA | 1ms | 3856kb | C++20 | 1.2kb | 2024-09-25 16:47:36 | 2024-09-25 16:47:41 |
Judging History
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);}
int a[50050];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
vector<int> vec;
int n;
cin>>n;
for(int i=n;i>=1;i--)
{
vector<int> v2;
while(sz(vec))
{
cout<<"? "<<i<<" "<<vec.back()<<endl;
char ch;
cin>>ch;
if(ch=='<') break;
v2.pb(vec.back());
vec.pop_back();
}
vec.pb(i);
rev(v2);
for(auto x:v2)
vec.pb(x);
}
rev(vec);
for(int i=1;i<=n;i++)
a[vec[i-1]]=i;
cout<<"! ";
for(int i=1;i<=n;i++)
cout<<a[i]<<" ";
cout<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3848kb
input:
5 > < > < > <
output:
? 4 5 ? 3 5 ? 2 3 ? 2 5 ? 1 3 ? 1 2 ! 2 3 1 5 4
result:
ok yeah, seems ok, spent 6 queries of 13
Test #2:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
1
output:
! 1
result:
ok yeah, seems ok, spent 0 queries of 6
Test #3:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
2 >
output:
? 1 2 ! 2 1
result:
ok yeah, seems ok, spent 1 queries of 8
Test #4:
score: 0
Accepted
time: 1ms
memory: 3852kb
input:
3 > > >
output:
? 2 3 ? 1 3 ? 1 2 ! 3 2 1
result:
ok yeah, seems ok, spent 3 queries of 10
Test #5:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
4 > > > > > <
output:
? 3 4 ? 2 4 ? 2 3 ? 1 4 ? 1 3 ? 1 2 ! 3 4 2 1
result:
ok yeah, seems ok, spent 6 queries of 11
Test #6:
score: 0
Accepted
time: 1ms
memory: 3816kb
input:
5 > > > > > < > > <
output:
? 4 5 ? 3 5 ? 3 4 ? 2 5 ? 2 4 ? 2 3 ? 1 5 ? 1 4 ? 1 2 ! 3 4 5 2 1
result:
ok yeah, seems ok, spent 9 queries of 13
Test #7:
score: 0
Accepted
time: 1ms
memory: 3792kb
input:
6 > > > > > < > > < > > <
output:
? 5 6 ? 4 6 ? 4 5 ? 3 6 ? 3 5 ? 3 4 ? 2 6 ? 2 5 ? 2 3 ? 1 6 ? 1 5 ? 1 2 ! 3 4 5 6 2 1
result:
ok yeah, seems ok, spent 12 queries of 15
Test #8:
score: 0
Accepted
time: 1ms
memory: 3856kb
input:
7 > > > > > < > > < > > < > > <
output:
? 6 7 ? 5 7 ? 5 6 ? 4 7 ? 4 6 ? 4 5 ? 3 7 ? 3 6 ? 3 4 ? 2 7 ? 2 6 ? 2 3 ? 1 7 ? 1 6 ? 1 2 ! 3 4 5 6 7 2 1
result:
ok yeah, seems ok, spent 15 queries of 16
Test #9:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
8 > > > > > < > > < > > < > > < > > <
output:
? 7 8 ? 6 8 ? 6 7 ? 5 8 ? 5 7 ? 5 6 ? 4 8 ? 4 7 ? 4 5 ? 3 8 ? 3 7 ? 3 4 ? 2 8 ? 2 7 ? 2 3 ? 1 8 ? 1 7 ? 1 2 ! 3 4 5 6 7 8 2 1
result:
ok yeah, seems ok, spent 18 queries of 18
Test #10:
score: -100
Wrong Answer
time: 0ms
memory: 3856kb
input:
9 > > > > > < > > < > > < > > < > > < > >
output:
? 8 9 ? 7 9 ? 7 8 ? 6 9 ? 6 8 ? 6 7 ? 5 9 ? 5 8 ? 5 6 ? 4 9 ? 4 8 ? 4 5 ? 3 9 ? 3 8 ? 3 4 ? 2 9 ? 2 8 ? 2 3 ? 1 9 ? 1 8 ? 1 2
result:
wrong answer didn't fit into 20 queries