用户输出
11
1 -5 1 -5 1 9 1 -5 1 -5 1
Special Judge 信息
Accepted | Correct. answer = 11
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#25418 | #1145. ddd 和渡渡鸟 | Accepted | 100 | 1865 ms | 21224 K | C++ 17 / 1.5 K | yukino | 2020-05-01 10:16:38 |
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef long long LL;
const int N = 1000005;
int a, b;
int e[N * 2], h[N], ne[N * 2];
int idx;
int arr[N];
int degree[N];
void add(int x, int y) {
e[idx] = y;
ne[idx] = h[x];
h[x] = idx++;
}
vector<int> work(int n) {
idx = 0;
memset(h, -1, sizeof h);
memset(degree, 0, sizeof degree);
vector<int> res;
for (int i = 1; i <= n; i++) {
if (i - a >= 0) {
add(i - a, i);
degree[i]++;
}
if (i - b >= 0) {
add(i, i - b);
degree[i - b]++;
}
}
queue<int> q;
for (int i = 0; i <= n; i++) {
if (degree[i] == 0) {
q.push(i);
}
}
int cnt = 0;
while (q.size()) {
int t = q.front();
q.pop();
//入队的是点的编号
arr[t] = ++cnt;
for (int i = h[t]; i != -1; i = ne[i]) {
int c = e[i];
degree[c]--;
if (!degree[c]) {
q.push(c);
}
}
}
if (cnt != n + 1) {
return res;
}
for (int i = 1; i <= n; i++) {
res.push_back(arr[i] - arr[i - 1]);
}
return res;
}
int main() {
scanf("%d%d", &a, &b);
int l = 1, r = 1000000;
while (l < r) {
int mid = l + r + 1 >> 1;
if (work(mid).size()) {
l = mid;
} else {
r = mid - 1;
}
}
auto ans = work(l);
printf("%d\n", ans.size());
for (auto z : ans) {
printf("%d ", z);
}
return 0;
}
用户输出
11
1 -5 1 -5 1 9 1 -5 1 -5 1
Special Judge 信息
Accepted | Correct. answer = 11
系统信息
Exited with return code 0
419
36 36 36 36 36 36 36 36 36 36 -385 36 36 36 36 36 36 36 36 36 36 36 -385 36 36 36 36 36 36 36 36
<1231 bytes omitted>
用户输出
419
36 36 36 36 36 36 36 36 36 36 -385 36 36 36 36 36 36 36 36 36 36 36 -385 36 36 36 36 36 36 36 36 36 36 36 -385 36 36 36 36 3
<1203 bytes omitted>
Special Judge 信息
Accepted | Correct. answer = 419
系统信息
Exited with return code 0
11223
3929 -7296 3929 3929 -7296 3929 3929 -7296 3929 3929 -7296 3929 3929 -7296 3929 3929 -7296 392
<59949 bytes omitted>
用户输出
11223
3929 -7296 3929 3929 -7296 3929 3929 -7296 3929 3929 -7296 3929 3929 -7296 3929 3929 -7296 3929 -7296 3929 3929 -7296 3929
<59921 bytes omitted>
Special Judge 信息
Accepted | Correct. answer = 11223
系统信息
Exited with return code 0
174689
1 1 1 1 1 1 1 1 -46349 1 1 1 1 1 1 1 1 -46349 1 1 1 1 1 1 1 1 128350 1 1 1 1 1 1 1 1 -46349 1
<446330 bytes omitted>
用户输出
174689
1 1 1 1 1 1 1 1 -46349 1 1 1 1 1 1 1 1 -46349 1 1 1 1 1 1 1 1 128350 1 1 1 1 1 1 1 1 -46349 1 1 1 1 1 1 1 1 -46349 1 1 1
<446302 bytes omitted>
Special Judge 信息
Accepted | Correct. answer = 174689
系统信息
Exited with return code 0
188827
1 -51075 1 -51075 1 137755 1 -51075 1 -51075 1 -51075 1 137755 1 -51075 1 -51075 1 -51075 1 1
<849626 bytes omitted>
用户输出
188827
1 -51075 1 -51075 1 137755 1 -51075 1 -51075 1 -51075 1 137755 1 -51075 1 -51075 1 -51075 1 137755 1 -51075 1 -51075 1 13
<849598 bytes omitted>
Special Judge 信息
Accepted | Correct. answer = 188827
系统信息
Exited with return code 0
210661
1 -33215 1 -33215 1 -33215 1 -33215 1 -33215 1 177449 1 -33215 1 -33215 1 -33215 1 -33215 1 -
<947879 bytes omitted>
用户输出
210661
1 -33215 1 -33215 1 -33215 1 -33215 1 -33215 1 177449 1 -33215 1 -33215 1 -33215 1 -33215 1 -33215 1 177449 1 -33215 1 -3
<947851 bytes omitted>
Special Judge 信息
Accepted | Correct. answer = 210661
系统信息
Exited with return code 0
366169
1 1 1 1 1 1 -102157 1 1 1 1 1 1 -102157 1 1 1 1 1 1 264020 1 1 1 1 1 1 -102157 1 1 1 1 1 1 -1
<1031507 bytes omitted>
用户输出
366169
1 1 1 1 1 1 -102157 1 1 1 1 1 1 -102157 1 1 1 1 1 1 264020 1 1 1 1 1 1 -102157 1 1 1 1 1 1 -102157 1 1 1 1 1 1 -102157 1
<1031479 bytes omitted>
Special Judge 信息
Accepted | Correct. answer = 366169
系统信息
Exited with return code 0
399999
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
<799921 bytes omitted>
用户输出
399999
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
<799893 bytes omitted>
Special Judge 信息
Accepted | Correct. answer = 399999
系统信息
Exited with return code 0
599997
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
<1199907 bytes omitted>
用户输出
599997
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
<1199879 bytes omitted>
Special Judge 信息
Accepted | Correct. answer = 599997
系统信息
Exited with return code 0
599997
-2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2
<1799902 bytes omitted>
用户输出
599997
-2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -
<1799874 bytes omitted>
Special Judge 信息
Accepted | Correct. answer = 599997
系统信息
Exited with return code 0
390556
191381 -199177 191381 -199177 191381 -199177 191381 -199177 191381 -199177 191381 -199177 191
<2925179 bytes omitted>
用户输出
390556
191381 -199177 191381 -199177 191381 -199177 191381 -199177 191381 -199177 191381 -199177 191381 -199177 191381 -199177 1
<2925151 bytes omitted>
Special Judge 信息
Accepted | Correct. answer = 390556
系统信息
Exited with return code 0
292643
1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -
<1316798 bytes omitted>
用户输出
292643
1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -15589 1 -1
<1316770 bytes omitted>
Special Judge 信息
Accepted | Correct. answer = 292643
系统信息
Exited with return code 0
517013
1 1 -105107 1 1 -105107 1 1 -105107 1 1 411910 1 1 -105107 1 1 -105107 1 1 -105107 1 1 -10510
<2032921 bytes omitted>
用户输出
517013
1 1 -105107 1 1 -105107 1 1 -105107 1 1 411910 1 1 -105107 1 1 -105107 1 1 -105107 1 1 -105107 1 1 411910 1 1 -105107 1 1
<2032893 bytes omitted>
Special Judge 信息
Accepted | Correct. answer = 517013
系统信息
Exited with return code 0
599995
1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1
<1199903 bytes omitted>
用户输出
599995
1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1
<1199875 bytes omitted>
Special Judge 信息
Accepted | Correct. answer = 599995
系统信息
Exited with return code 0
用户输出
0
Special Judge 信息
Accepted | Correct. answer = 0
系统信息
Exited with return code 0
299999
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
<599905 bytes omitted>
用户输出
299999
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
<599877 bytes omitted>
Special Judge 信息
Accepted | Correct. answer = 299999
系统信息
Exited with return code 0