QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#589225#7535. Limited Shuffle RestoringKevin5307WA 1ms3564kbC++201.2kb2024-09-25 16:46:432024-09-25 16:46:49

Judging History

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

  • [2024-09-25 16:46:49]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3564kb
  • [2024-09-25 16:46:43]
  • 提交

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);
	}
	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;
}

详细

Test #1:

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

input:

5
>
<
>
<
>
<

output:

? 4 5
? 3 5
? 2 3
? 2 5
? 1 3
? 1 2
! 4 3 5 1 2 

result:

wrong answer the constraint a[4] > a[5] is not satisfied