QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#694954#6728. To the ParkShuishui#WA 137ms4896kbC++141.4kb2024-10-31 19:01:172024-10-31 19:01:17

Judging History

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

  • [2024-10-31 19:01:17]
  • 评测
  • 测评结果:WA
  • 用时:137ms
  • 内存:4896kb
  • [2024-10-31 19:01:17]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define Sz(x) (int)(x).size()
#define bit(x) (1ll << (x))
using ll = long long;
using db = double;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vd = vector<db>;
mt19937 mrand(time(0));

void solve(void)
{
	int n;
	cin >> n;
	vi vis(n + 2);
	vector<array<int, 2>> ans;
	for (int i = n; i >= 1; i--)
	{
		int bd = 0;
		for (int d = 2; d * d <= i; d++)
		{
			bd = d;
			if (i % d == 0 && !vis[i / d])
			{
				ans.pb({i, i / d});
				vis[i] = vis[i / d] = 1;
				break;
			}
		}

		if (!vis[i])
		{
			for (int d = bd; d >= 2; d--)
			{
				// cerr << i << " " << d << "\n";
				if (i % d == 0 && !vis[d])
				{
					ans.pb({i, d});
					vis[i] = vis[d] = 1;
					break;
				}			
			}
		}

	}
	// cerr << "GG\n";

	int m = Sz(ans);
	cout << m << " \n"[m == 0];
	for (int i = 0; i < m; i++)
		cout << ans[i][0] << " " << ans[i][1] << " \n"[i == m - 1];
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// cout << fixed << setprecision(10);

	int T = 1;
	cin >> T;
	for (int i = 1; i <= T; i++)
	solve();

	return 0;
}

详细

Test #1:

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

input:

3
1
4
6

output:

0
1 4 2
2 6 3 4 2

result:

ok 4 cases

Test #2:

score: -100
Wrong Answer
time: 137ms
memory: 4896kb

input:

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

output:

0
0
0
1 4 2
1 4 2
2 6 3 4 2
2 6 3 4 2
3 8 4 6 3 4 2
3 9 3 8 4 6 2
4 10 5 9 3 8 4 6 2
4 10 5 9 3 8 4 6 2
5 12 6 10 5 9 3 8 4 4 2
5 12 6 10 5 9 3 8 4 4 2
6 14 7 12 6 10 5 9 3 8 4 4 2
6 15 5 14 7 12 6 10 2 9 3 8 4
7 16 8 15 5 14 7 12 6 10 2 9 3 8 4
7 16 8 15 5 14 7 12 6 10 2 9 3 8 4
8 18 9 16 8 15 5 14...

result:

wrong answer Case #8: Duplicate person 4