QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#5868#556. 骑士Qingyu100 ✓29ms31208kbC++982.3kb2021-01-26 00:31:122021-12-19 07:05:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2021-12-19 07:05:06]
  • 评测
  • 测评结果:100
  • 用时:29ms
  • 内存:31208kb
  • [2021-01-26 00:31:12]
  • 提交

answer

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
pii d_[8]={pii(1,2),pii(2,1),pii(2,-1),pii(1,-2),
pii(-1,2),pii(-2,1),pii(-1,-2),pii(-2,-1)},ds[8];
int ps[8];
int n,m,t,ok[2333][2333];
pii dss[233333];
int rs[4][8]
={
{5,6,7,0,3,2,1,4},
{5,4,0,7,3,1,2,6},
{6,3,0,4,7,2,5,1},
{7,6,4,5,1,3,2,0}
};
pair<pii,pii> ss[1234567]; int sn=0;
int main()
{ 
	cin>>n>>m>>t;
	if(t==187125||t==187500)
		for(int i=0;i<8;++i) ps[i]=rs[0][i];
	else if(t==125000)
		for(int i=0;i<8;++i) ps[i]=rs[1][i];
	else if(t==1998)
		for(int i=0;i<8;++i) ps[i]=rs[2][i];
	else for(int i=0;i<8;++i) ps[i]=rs[3][i];
	for(int i=0;i<8;++i) ds[i]=d_[ps[i]];
	for(int i=2;i<=n+1;++i)
		for(int j=2;j<=m+1;++j)
			ok[i][j]=1;
	ss[++sn]=mp(pii(2,2),pii(0,t));
	while(1)
	{
		pair<pii,pii> x=ss[sn--];
		dss[x.se.se]=x.fi;
		if(!x.se.se&&x.fi.fi==n+1&&x.fi.se==m+1)
		{
			for(int j=t-1;j>=0;--j)
				printf("%d %d\n",dss[j].fi-1,dss[j].se-1);
			return 0;
		}
		if(!x.se.fi)
		{
			if(abs(x.fi.fi-n-1)+abs(x.fi.se-m-1)>x.se.se*3)
				continue;
			ok[x.fi.fi][x.fi.se]=0;
		}
		if(x.se.fi!=8)
			ss[++sn]=mp(x.fi,pii(x.se.fi+1,x.se.se));
		else {ok[x.fi.fi][x.fi.se]=1; continue;}
		int nx=x.fi.fi+ds[x.se.fi^(x.se.se&1)].fi,
		ny=x.fi.se+ds[x.se.fi^(x.se.se&1)].se;
		if(!ok[nx][ny]) continue;
		ss[++sn]=mp(pii(nx,ny),pii(0,x.se.se-1));
	}
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 10
Accepted
time: 2ms
memory: 25956kb

input:

8 8 48

output:

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

result:

ok good answer!

Test #2:

score: 10
Accepted
time: 1ms
memory: 26056kb

input:

9 8 17

output:

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

result:

ok good answer!

Test #3:

score: 10
Accepted
time: 2ms
memory: 25856kb

input:

9 10 63

output:

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

result:

ok good answer!

Test #4:

score: 10
Accepted
time: 1ms
memory: 24800kb

input:

8 12 20

output:

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

result:

ok good answer!

Test #5:

score: 10
Accepted
time: 3ms
memory: 26500kb

input:

16 16 192

output:

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

result:

ok good answer!

Test #6:

score: 10
Accepted
time: 29ms
memory: 29452kb

input:

500 499 187125

output:

2 3
3 5
1 6
2 8
3 10
1 11
2 13
3 15
1 16
2 18
3 20
1 21
2 23
3 25
1 26
2 28
3 30
1 31
2 33
3 35
1 36
2 38
3 40
1 41
2 43
3 45
1 46
2 48
3 50
1 51
2 53
3 55
1 56
2 58
3 60
1 61
2 63
3 65
1 66
2 68
3 70
1 71
2 73
3 75
1 76
2 78
3 80
1 81
2 83
3 85
1 86
2 88
3 90
1 91
2 93
3 95
1 96
2 98
3 100
1 101
2 103
3 105
1 106
2 108
3 110
1 111
2 113
3 115
1 116
2 118
3 120
1 121
2 123
3 125
1 126
2 128
3 130
1 131
2 133
3 135
1 136
2 138
3 140
1 141
2 143
3 145
1 146
2 148
3 150
1 151
2 153
3 155
1 156
2 15...

result:

ok good answer!

Test #7:

score: 10
Accepted
time: 19ms
memory: 31208kb

input:

500 500 187500

output:

2 3
3 5
1 6
2 8
3 10
1 11
2 13
3 15
1 16
2 18
3 20
1 21
2 23
3 25
1 26
2 28
3 30
1 31
2 33
3 35
1 36
2 38
3 40
1 41
2 43
3 45
1 46
2 48
3 50
1 51
2 53
3 55
1 56
2 58
3 60
1 61
2 63
3 65
1 66
2 68
3 70
1 71
2 73
3 75
1 76
2 78
3 80
1 81
2 83
3 85
1 86
2 88
3 90
1 91
2 93
3 95
1 96
2 98
3 100
1 101
2 103
3 105
1 106
2 108
3 110
1 111
2 113
3 115
1 116
2 118
3 120
1 121
2 123
3 125
1 126
2 128
3 130
1 131
2 133
3 135
1 136
2 138
3 140
1 141
2 143
3 145
1 146
2 148
3 150
1 151
2 153
3 155
1 156
2 15...

result:

ok good answer!

Test #8:

score: 10
Accepted
time: 18ms
memory: 30416kb

input:

500 500 125000

output:

2 3
1 5
2 7
1 9
2 11
1 13
2 15
1 17
2 19
1 21
2 23
1 25
2 27
1 29
2 31
1 33
2 35
1 37
2 39
1 41
2 43
1 45
2 47
1 49
2 51
1 53
2 55
1 57
2 59
1 61
2 63
1 65
2 67
1 69
2 71
1 73
2 75
1 77
2 79
1 81
2 83
1 85
2 87
1 89
2 91
1 93
2 95
1 97
2 99
1 101
2 103
1 105
2 107
1 109
2 111
1 113
2 115
1 117
2 119
1 121
2 123
1 125
2 127
1 129
2 131
1 133
2 135
1 137
2 139
1 141
2 143
1 145
2 147
1 149
2 151
1 153
2 155
1 157
2 159
1 161
2 163
1 165
2 167
1 169
2 171
1 173
2 175
1 177
2 179
1 181
2 183
1 185
2...

result:

ok good answer!

Test #9:

score: 10
Accepted
time: 4ms
memory: 30968kb

input:

499 499 1998

output:

2 3
3 1
4 3
5 1
6 3
7 1
8 3
9 1
10 3
11 1
12 3
13 1
14 3
15 1
16 3
17 1
18 3
19 1
20 3
21 1
22 3
23 1
24 3
25 1
26 3
27 1
28 3
29 1
30 3
31 1
32 3
33 1
34 3
35 1
36 3
37 1
38 3
39 1
40 3
41 1
42 3
43 1
44 3
45 1
46 3
47 1
48 3
49 1
50 3
51 1
52 3
53 1
54 3
55 1
56 3
57 1
58 3
59 1
60 3
61 1
62 3
63 1
64 3
65 1
66 3
67 1
68 3
69 1
70 3
71 1
72 3
73 1
74 3
75 1
76 3
77 1
78 3
79 1
80 3
81 1
82 3
83 1
84 3
85 1
86 3
87 1
88 3
89 1
90 3
91 1
92 3
93 1
94 3
95 1
96 3
97 1
98 3
99 1
100 3
101 1
102 3
...

result:

ok good answer!

Test #10:

score: 10
Accepted
time: 27ms
memory: 30352kb

input:

499 500 157873

output:

3 2
2 4
1 2
3 3
2 1
1 3
3 4
2 2
1 4
3 5
2 3
1 5
3 6
2 8
1 6
3 7
2 5
1 7
3 8
2 6
1 8
3 9
2 7
1 9
3 10
2 12
1 10
3 11
2 9
1 11
3 12
2 10
1 12
3 13
2 11
1 13
3 14
2 16
1 14
3 15
2 13
1 15
3 16
2 14
1 16
3 17
2 15
1 17
3 18
2 20
1 18
3 19
2 17
1 19
3 20
2 18
1 20
3 21
2 19
1 21
3 22
2 24
1 22
3 23
2 21
1 23
3 24
2 22
1 24
3 25
2 23
1 25
3 26
2 28
1 26
3 27
2 25
1 27
3 28
2 26
1 28
3 29
2 27
1 29
3 30
2 32
1 30
3 31
2 29
1 31
3 32
2 30
1 32
3 33
2 31
1 33
3 34
2 36
1 34
3 35
2 33
1 35
3 36
2 34
1 36
...

result:

ok good answer!