QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#32401#1813. Joy with PermutationsAppleblue17WA 74ms3864kbC++1.4kb2022-05-19 20:51:032024-04-09 18:56:03

Judging History

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

  • [2024-04-09 18:56:03]
  • 管理员手动重测本题所有提交记录
  • 测评结果:WA
  • 用时:74ms
  • 内存:3864kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-19 20:51:05]
  • 评测
  • 测评结果:0
  • 用时:546ms
  • 内存:3804kb
  • [2022-05-19 20:51:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=66000;
int n;
int query(int x,int y,int z){
	cout<<"? 1 "<<x<<" "<<y<<" "<<z<<endl;
	int tot;
	cin>>tot;
	return tot;
}
int A,B,C,D,mn,mx;
pair <int,int> a[4];
int ans[N];

int main(){
	cin>>n;
	a[0]=make_pair(query(1,2,3),(1|2|4)),a[1]=make_pair(query(1,3,4),(1|4|8)),
	a[2]=make_pair(query(1,2,4),(1|2|8)),a[3]=make_pair(query(2,3,4),(2|4|8));
	sort(a,a+4);
	int x=a[0].second & a[1].second,y=a[2].second & a[3].second;
	if(x==3) A=1,B=2;
	else if(x==5) A=1,B=3;
	else if(x==9) A=1,B=4;
	else if(x==6) A=2,B=3;
	else if(x==10) A=2,B=4;
	else if(x==12) A=3,B=4;
	
	if(y==3) C=1,D=2;
	else if(y==5) C=1,D=3;
	else if(y==9) C=1,D=4;
	else if(y==6) C=2,D=3;
	else if(y==10) C=2,D=4;
	else if(y==12) C=3,D=4;
	
	mn=a[0].first,mx=a[2].first;
	
	for(int i=5;i<=n;i++){
		int x=query(A,C,i);
		if(x==mn){
			ans[A]=mn;
			A=i;
		}
		else if(x==mx){
			ans[C]=mx;
			C=i;
		}
		else if(mn<x && x<mx){
			ans[i]=x;
		}
		else if(x<mn){
			ans[B]=mn;
			mn=x;
			B=i;
		}
		else if(x>mx){
			ans[D]=mx;
			mx=x;
			D=i;
		}
	}
	
	cout<<"? 2 "<<A<<" "<<B<<endl;
	cin>>x;
	if(x==A) ans[A]=1,ans[B]=2;
	else ans[A]=2,ans[B]=1;
	
	cout<<"? 2 "<<C<<" "<<D<<endl;
	cin>>x;
	if(x==C) ans[C]=n-1,ans[D]=n;
	else ans[C]=n,ans[D]=n-1;
	
	cout<<"! ";
	for(int i=1;i<=n;i++) cout<<ans[i]<<" ";
	cout<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
4
3
3
4
3
4
3

output:

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

result:

ok OK (5 2)

Test #2:

score: -100
Wrong Answer
time: 74ms
memory: 3864kb

input:

60000
2
2
3
3
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
52
53...

output:

? 1 1 2 3
? 1 1 3 4
? 1 1 2 4
? 1 2 3 4
? 1 1 2 5
? 1 1 5 6
? 1 1 5 7
? 1 1 7 8
? 1 1 7 9
? 1 1 9 10
? 1 1 9 11
? 1 1 11 12
? 1 1 11 13
? 1 1 13 14
? 1 1 13 15
? 1 1 15 16
? 1 1 15 17
? 1 1 17 18
? 1 1 17 19
? 1 1 19 20
? 1 1 19 21
? 1 1 21 22
? 1 1 21 23
? 1 1 23 24
? 1 1 23 25
? 1 1 25 26
? 1 1 25...

result:

wrong answer wrong answer