编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#114673 | #1145. ddd 和渡渡鸟 | Compile Error | 0 | 0 ms | 0 K | C++ 11 / 925 B | Rhodoks | 2024-07-22 20:36:03 |
#include <bits/stdc++.h>
using namespace std;
vector<int> g[MAXN];
int in[MAXN];
int sum[MAXN];
int x, y;
bool check(int mid) {
for (int i = 0; i <= mid; i++) {
g[i].clear();
in[i] = 0;
}
for (int i = 0; i <= mid; i++) {
if (i + a <= mid) {
g[i].push_back(i + x);
in[i + x]++;
}
if (i + b <= mid) {
g[i + y].push_back(i);
in[i]++;
}
}
int cnt = 0;
queue<int> q;
for (int i = 0; i <= mid; i++)
if (in[i] == 0)
q.push(i);
while (!q.empty()) {
int pos = q.front();
q.pop();
sum[pos] = cnt++;
for (auto p : g[pos]) {
in[p]--;
if (!in[p])
q.push(p);
}
}
if (cnt == mid + 1)
return 1;
return 0;
}
int main() {
cin >> x >> y;
int l = 1, r = x + y + 10;
while (l != r) {
int mid = (l + r) / 2;
if (check(mid))
l = mid + 1;
else
r = mid;
}
l--;
check(l);
cout << l << endl;
for (int i = 1; i <= l; i++) printf("%d ", sum[i] - sum[i - 1]);
return 0;
}
编译信息
/sandbox/1/a.cpp:5:15: error: 'MAXN' was not declared in this scope
5 | vector<int> g[MAXN];
| ^~~~
/sandbox/1/a.cpp:6:8: error: 'MAXN' was not declared in this scope
6 | int in[MAXN];
| ^~~~
/sandbox/1/a.cpp:7:9: error: 'MAXN' was not declared in this scope
7 | int sum[MAXN];
| ^~~~
/sandbox/1/a.cpp: In function 'bool check(int)':
/sandbox/1/a.cpp:15:3: error: 'g' was not declared in this scope
15 | g[i].clear();
| ^
/sandbox/1/a.cpp:16:3: error: 'in' was not declared in this scope; did you mean 'i'?
16 | in[i]=0;
| ^~
| i
/sandbox/1/a.cpp:20:9: error: 'a' was not declared in this scope
20 | if (i+a<=mid)
| ^
/sandbox/1/a.cpp:22:4: error: 'g' was not declared in this scope
22 | g[i].push_back(i+x);
| ^
/sandbox/1/a.cpp:23:4: error: 'in' was not declared in this scope; did you mean 'i'?
23 | in[i+x]++;
| ^~
| i
/sandbox/1/a.cpp:25:9: error: 'b' was not declared in this scope
25 | if (i+b<=mid)
| ^
/sandbox/1/a.cpp:27:4: error: 'g' was not declared in this scope
27 | g[i+y].push_back(i);
| ^
/sandbox/1/a.cpp:28:4: error: 'in' was not declared in this scope; did you mean 'i'?
28 | in[i]++;
| ^~
| i
/sandbox/1/a.cpp:34:7: error: 'in' was not declared in this scope; did you mean 'i'?
34 | if (in[i]==0)
| ^~
| i
/sandbox/1/a.cpp:40:3: error: 'sum' was not declared in this scope
40 | sum[pos]=cnt++;
| ^~~
/sandbox/1/a.cpp:41:15: error: 'g' was not declared in this scope
41 | for (auto p:g[pos])
| ^
/sandbox/1/a.cpp:43:4: error: 'in' was not declared in this scope; did you mean 'yn'?
43 | in[p]--;
| ^~
| yn
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:69:16: error: 'sum' was not declared in this scope
69 | printf("%d ",sum[i]-sum[i-1]);
| ^~~