QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#562844#1837. Hamiltonianydzr00000AC ✓1ms3940kbC++17818b2024-09-13 21:30:172024-09-13 21:30:18

Judging History

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

  • [2024-09-13 21:30:18]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3940kb
  • [2024-09-13 21:30:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int main(){
	int k;
	cin>>k;
	if(k==1)
	{
		puts("2 1");
		puts("1 2");
		return 0;
	}
	if(k==2)
	{
		puts("4 4");
		puts("1 2");
		puts("1 3");
		puts("2 3");
		puts("2 4");
		return 0;
	}
	if(k<=20)
	{
		printf("%d %d\n",k,k);
		for(int i=1;i<=k;i++)
			printf("%d %d\n",i,i%k+1);
		return 0;
	}
	for(int i=10;i>=3;i--)
		for(int j=4;j<=20;j++)
		{
			int all=i+j-2;
			if(all>20)
				break;
			int num=i*(i-1)/2+2*(i-1)+(j-3)-1;
			if(num==k)
			{
				int n=all,m=i*(i-1)/2+(j-1);
				printf("%d %d\n",n,m);
				for(int p=1;p<=i;p++)
					for(int q=1;q<p;q++)
						printf("%d %d\n",p,q);
				for(int p=1;p<=j-2;p++)
					printf("%d %d\n",i+p-1,i+p);
				printf("%d %d\n",i+j-2,i-1);
				return 0;
			}
		}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3700kb

input:

1

output:

2 1
1 2

result:

ok correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

2

output:

4 4
1 2
1 3
2 3
2 4

result:

ok correct

Test #3:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

3

output:

3 3
1 2
2 3
3 1

result:

ok correct

Test #4:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

4

output:

4 4
1 2
2 3
3 4
4 1

result:

ok correct

Test #5:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

5

output:

5 5
1 2
2 3
3 4
4 5
5 1

result:

ok correct

Test #6:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

6

output:

6 6
1 2
2 3
3 4
4 5
5 6
6 1

result:

ok correct

Test #7:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

7

output:

7 7
1 2
2 3
3 4
4 5
5 6
6 7
7 1

result:

ok correct

Test #8:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

8

output:

8 8
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 1

result:

ok correct

Test #9:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

9

output:

9 9
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 1

result:

ok correct

Test #10:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

10

output:

10 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 1

result:

ok correct

Test #11:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

11

output:

11 11
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 1

result:

ok correct

Test #12:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

12

output:

12 12
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 1

result:

ok correct

Test #13:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

13

output:

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

result:

ok correct

Test #14:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

14

output:

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

result:

ok correct

Test #15:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

15

output:

15 15
1 2
2 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 1

result:

ok correct

Test #16:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

16

output:

16 16
1 2
2 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 1

result:

ok correct

Test #17:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

17

output:

17 17
1 2
2 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 1

result:

ok correct

Test #18:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

18

output:

18 18
1 2
2 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 1

result:

ok correct

Test #19:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

19

output:

19 19
1 2
2 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 1

result:

ok correct

Test #20:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

20

output:

20 20
1 2
2 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 1

result:

ok correct

Test #21:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

21

output:

10 16
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
5 6
6 7
7 8
8 9
9 10
10 4

result:

ok correct

Test #22:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

22

output:

11 17
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
5 6
6 7
7 8
8 9
9 10
10 11
11 4

result:

ok correct

Test #23:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

23

output:

12 18
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 4

result:

ok correct

Test #24:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

24

output:

13 19
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 4

result:

ok correct

Test #25:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

25

output:

8 18
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
6 7
7 8
8 5

result:

ok correct

Test #26:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

26

output:

9 19
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
6 7
7 8
8 9
9 5

result:

ok correct

Test #27:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

27

output:

10 20
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
6 7
7 8
8 9
9 10
10 5

result:

ok correct

Test #28:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

28

output:

11 21
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
6 7
7 8
8 9
9 10
10 11
11 5

result:

ok correct

Test #29:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

29

output:

12 22
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
6 7
7 8
8 9
9 10
10 11
11 12
12 5

result:

ok correct

Test #30:

score: 0
Accepted
time: 0ms
memory: 3784kb

input:

30

output:

13 23
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 5

result:

ok correct

Test #31:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

31

output:

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

result:

ok correct

Test #32:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

32

output:

15 25
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 5

result:

ok correct

Test #33:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

33

output:

9 24
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
7 8
8 9
9 6

result:

ok correct

Test #34:

score: 0
Accepted
time: 0ms
memory: 3936kb

input:

34

output:

10 25
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
7 8
8 9
9 10
10 6

result:

ok correct

Test #35:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

35

output:

11 26
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
7 8
8 9
9 10
10 11
11 6

result:

ok correct

Test #36:

score: 0
Accepted
time: 0ms
memory: 3936kb

input:

36

output:

12 27
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
7 8
8 9
9 10
10 11
11 12
12 6

result:

ok correct

Test #37:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

37

output:

13 28
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
7 8
8 9
9 10
10 11
11 12
12 13
13 6

result:

ok correct

Test #38:

score: 0
Accepted
time: 0ms
memory: 3936kb

input:

38

output:

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

result:

ok correct

Test #39:

score: 0
Accepted
time: 1ms
memory: 3756kb

input:

39

output:

15 30
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 6

result:

ok correct

Test #40:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

40

output:

16 31
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 6

result:

ok correct

Test #41:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

41

output:

17 32
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 6

result:

ok correct

Test #42:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

42

output:

10 31
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 9
9 10
10 7

result:

ok correct

Test #43:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

43

output:

11 32
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 9
9 10
10 11
11 7

result:

ok correct

Test #44:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

44

output:

12 33
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 9
9 10
10 11
11 12
12 7

result:

ok correct

Test #45:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

45

output:

13 34
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 9
9 10
10 11
11 12
12 13
13 7

result:

ok correct

Test #46:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

46

output:

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

result:

ok correct

Test #47:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

47

output:

15 36
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 7

result:

ok correct

Test #48:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

48

output:

16 37
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 7

result:

ok correct

Test #49:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

49

output:

17 38
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 7

result:

ok correct

Test #50:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

50

output:

18 39
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 7

result:

ok correct

Test #51:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

51

output:

19 40
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 7

result:

ok correct

Test #52:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

52

output:

11 39
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
9 10
10 11
11 8

result:

ok correct

Test #53:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

53

output:

12 40
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
9 10
10 11
11 12
12 8

result:

ok correct

Test #54:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

54

output:

13 41
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
9 10
10 11
11 12
12 13
13 8

result:

ok correct

Test #55:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

55

output:

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

result:

ok correct

Test #56:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

56

output:

15 43
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
9 10
10 11
11 12
12 13
13 14
14 15
15 8

result:

ok correct

Test #57:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

57

output:

16 44
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 8

result:

ok correct

Test #58:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

58

output:

17 45
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 8

result:

ok correct

Test #59:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

59

output:

18 46
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 8

result:

ok correct

Test #60:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

60

output:

19 47
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 8

result:

ok correct