QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#383903#1813. Joy with PermutationsCrysflyWA 158ms3844kbC++171.8kb2024-04-09 18:39:192024-04-09 18:57:28

Judging History

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

  • [2024-04-09 18:57:28]
  • 管理员手动重测本题所有提交记录
  • 测评结果:WA
  • 用时:158ms
  • 内存:3844kb
  • [2024-04-09 18:39:19]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3488kb
  • [2024-04-09 18:39:19]
  • 提交

answer

// what is matter? never mind. 
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define int long long
#define ull unsigned long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 2000005
#define inf 0x3f3f3f3f

int n,res[maxn];
vi p,q;

int Q(vi o){
	cout<<"? "<<1<<" ";
	for(int x:o)cout<<x<<" ";
	cout<<endl;
	int x;cin>>x;return x;
}

signed main()
{
	cin>>n;
	vi w;
	For(i,1,4){
		vi o;
		For(j,1,4) if(i!=j) o.pb(j);
		w.pb(Q(o));
	}
	vi p={1,2,3,4};
	sort(ALL(p),[&](int x,int y){return w[x-1]>w[y-1];});
	int a,b,c,d,l,r;
	// [a,b]=(l),[c,d]=(r)
	a=p[0],b=p[1],c=p[2],d=p[3];
	r=w[a],l=w[d];
	For(i,4,n){
		int x=Q({a,c,i});
		if(x>l && x<r) {
			res[i]=x;
			continue;
		}
		if(x<=l){
			if(x<l) res[b]=l,b=i;
			else res[a]=l,a=i;
			l=Q({a,b,c});
		}else{
			if(x>r) res[d]=r,d=i;
			else res[c]=l,c=i;
			r=Q({a,c,d});
		}
	}
	cout<<"? "<<2<<" "<<a<<" "<<b<<endl;
	int x;cin>>x;
	if(x==a) res[a]=1,res[b]=2;
	else res[a]=2,res[b]=1;
	cout<<"? "<<2<<" "<<c<<" "<<d<<endl;
	cin>>x;
	if(x==c) res[c]=n-1,res[d]=n;
	else res[c]=n,res[d]=n-1;
	cout<<"! ";For(i,1,n)cout<<res[i]<<" "; cout<<endl;
	return 0;
}
/*
1 2 3
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3600kb

input:

5
4
3
3
4
3
3
3
2
4
3

output:

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

result:

ok OK (8 2)

Test #2:

score: -100
Wrong Answer
time: 158ms
memory: 3844kb

input:

60000
2
2
3
3
2
2
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
11
11
12
12
13
13
14
14
15
15
16
16
17
17
18
18
19
19
20
20
21
21
22
22
23
23
24
24
25
25
26
26
27
27
28
28
29
29
30
30
31
31
32
32
33
33
34
34
35
35
36
36
37
37
38
38
39
39
40
40
41
41
42
42
43
43
44
44
45
45
46
46
47
47
48
48
49
49
50
50
51
51
52
5...

output:

? 1 2 3 4 
? 1 1 3 4 
? 1 1 2 4 
? 1 1 2 3 
? 1 3 1 4 
? 1 3 4 1 
? 1 3 1 5 
? 1 3 5 2 
? 1 3 5 6 
? 1 3 6 2 
? 1 3 6 7 
? 1 3 7 2 
? 1 3 7 8 
? 1 3 8 2 
? 1 3 8 9 
? 1 3 9 2 
? 1 3 9 10 
? 1 3 10 2 
? 1 3 10 11 
? 1 3 11 2 
? 1 3 11 12 
? 1 3 12 2 
? 1 3 12 13 
? 1 3 13 2 
? 1 3 13 14 
? 1 3 14 2 
...

result:

wrong answer wrong answer