QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#175259#7178. Bishopsucup-team956#WA 25ms14184kbC++202.3kb2023-09-10 17:04:582023-09-10 17:04:58

Judging History

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

  • [2023-09-10 17:04:58]
  • 评测
  • 测评结果:WA
  • 用时:25ms
  • 内存:14184kb
  • [2023-09-10 17:04:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define time chrono::system_clock::now().time_since_epoch().count()
mt19937_64 rnd(time);
#define maxn 1000005
#define int long long

int read() {int x;cin>>x;return x;}

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

	int n = read(), m = read(), op = 0;
	if(n > m) swap(n, m), op = 1;
	vector<pair<int,int>>ans;
	if(n == 1) {
		for(int i = 1; i <= m; i++) {
			ans.push_back({i, 1});
		}
		cout << ans.size() << "\n";
		for(auto [x, y]:ans) {
			if(!op) cout << y << " " << x <<"\n";
			else cout << x << " " << y <<"\n";
		}
		return 0;
	}
	int x = (n + 1) / 2;
	int y = n / 2;
	vector<int>vis(n + m + n + m);
	vector vis1 = vis;
	for(int i = 1; i <= m; i += 2 * x) {
		for(int j = 1; j <= n; j += 2) {
			assert(vis[i - j + n] == 0);
			ans.push_back({i, j});
			vis[i - j + n] = 1;
			vis1[i + j] = 1; 
		}
	}
	int ba = 1, oo = 0;
	// if(n % 2 == 1) ba = 2;
	// else ba = 1;
	
	if(m % 2 == 0) {
		if(m % 2 == 1) ba = 1;
		else ba = 2;
		for(int i = ba; i <= n; i += 2) {
			if(vis[m - i + n] == 0 && vis1[m + i] == 0) {
				vis[m - i + n] = 1;
				vis1[m + i] = 1;
				ans.push_back({m, i});
			}
		}
		vector<pair<int,int>>an;
		for(auto [x, y]:ans) {
			an.push_back({m - x + 1, y});
			// if(!op) cout << y << " " << x <<"\n";
			// else cout << x << " " << y <<"\n";
		}
		cout << ans.size() + an.size() << "\n";
		for(auto [x, y]:ans) {
			if(!op) cout << y << " " << x <<"\n";
			else cout << x << " " << y <<"\n";
		}
		for(auto [x, y]:an) {
			if(!op) cout << y << " " << x <<"\n";
			else cout << x << " " << y <<"\n";
		}
		return 0;
	}
	for(int i = 1; i <= m;) {
		int fi;
		if(oo == 0) fi = 2;
		else fi = 1;
		for(int j = fi; j <= n; j += 2) {
			assert(vis[i - j + n] == 0);
			ans.push_back({i, j});
			vis[i - j + n] = 1;
			vis1[i + j] = 1; 
		}
		if(x == y) {
			i += 2 * x;
			continue;
		} 
		if(oo == 0) {
			oo = 1;
			i ++;
			i += 2 * y;
		}
		else {i += 2 * x;}
	}
	for(int i = 1; i <= n; i += 1) {
		if(vis[m - i + n] == 0 && vis1[m + i] == 0) {
			vis[m - i + n] = 1;
			vis1[m + i] = 1;
			ans.push_back({m, i});
		}
	}
	cout << ans.size() << "\n";
	for(auto [x, y]:ans) {
		if(!op) cout << y << " " << x <<"\n";
		else cout << x << " " << y <<"\n";
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 5

output:

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

result:

ok n: 2, m: 5, bishops: 6

Test #2:

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

input:

5 5

output:

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

result:

ok n: 5, m: 5, bishops: 8

Test #3:

score: 0
Accepted
time: 25ms
memory: 14184kb

input:

100000 100000

output:

199998
1 1
3 1
5 1
7 1
9 1
11 1
13 1
15 1
17 1
19 1
21 1
23 1
25 1
27 1
29 1
31 1
33 1
35 1
37 1
39 1
41 1
43 1
45 1
47 1
49 1
51 1
53 1
55 1
57 1
59 1
61 1
63 1
65 1
67 1
69 1
71 1
73 1
75 1
77 1
79 1
81 1
83 1
85 1
87 1
89 1
91 1
93 1
95 1
97 1
99 1
101 1
103 1
105 1
107 1
109 1
111 1
113 1
115 1
...

result:

ok n: 100000, m: 100000, bishops: 199998

Test #4:

score: 0
Accepted
time: 21ms
memory: 14060kb

input:

100000 99999

output:

199998
1 1
1 3
1 5
1 7
1 9
1 11
1 13
1 15
1 17
1 19
1 21
1 23
1 25
1 27
1 29
1 31
1 33
1 35
1 37
1 39
1 41
1 43
1 45
1 47
1 49
1 51
1 53
1 55
1 57
1 59
1 61
1 63
1 65
1 67
1 69
1 71
1 73
1 75
1 77
1 79
1 81
1 83
1 85
1 87
1 89
1 91
1 93
1 95
1 97
1 99
1 101
1 103
1 105
1 107
1 109
1 111
1 113
1 115
...

result:

ok n: 100000, m: 99999, bishops: 199998

Test #5:

score: 0
Accepted
time: 15ms
memory: 12048kb

input:

100000 50000

output:

149998
1 1
1 3
1 5
1 7
1 9
1 11
1 13
1 15
1 17
1 19
1 21
1 23
1 25
1 27
1 29
1 31
1 33
1 35
1 37
1 39
1 41
1 43
1 45
1 47
1 49
1 51
1 53
1 55
1 57
1 59
1 61
1 63
1 65
1 67
1 69
1 71
1 73
1 75
1 77
1 79
1 81
1 83
1 85
1 87
1 89
1 91
1 93
1 95
1 97
1 99
1 101
1 103
1 105
1 107
1 109
1 111
1 113
1 115
...

result:

ok n: 100000, m: 50000, bishops: 149998

Test #6:

score: 0
Accepted
time: 5ms
memory: 5228kb

input:

1 100000

output:

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

result:

ok n: 1, m: 100000, bishops: 100000

Test #7:

score: -100
Wrong Answer
time: 12ms
memory: 9468kb

input:

34535 99889

output:

130704
1 1
3 1
5 1
7 1
9 1
11 1
13 1
15 1
17 1
19 1
21 1
23 1
25 1
27 1
29 1
31 1
33 1
35 1
37 1
39 1
41 1
43 1
45 1
47 1
49 1
51 1
53 1
55 1
57 1
59 1
61 1
63 1
65 1
67 1
69 1
71 1
73 1
75 1
77 1
79 1
81 1
83 1
85 1
87 1
89 1
91 1
93 1
95 1
97 1
99 1
101 1
103 1
105 1
107 1
109 1
111 1
113 1
115 1
...

result:

wrong answer Participant's answer is not optimal (130704 < 134423)