编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#47000 | #1145. ddd 和渡渡鸟 | Compile Error | 0 | 0 ms | 0 K | C++ / 1.3 K | gggg | 2020-12-24 9:56:09 |
// Author: Yang Dong
#include <bits/stdc++.h>
using namespace std;
int a, b; // a pos, b neg
vector<int> check(int x) {
vector<int> ret, val(x + 1);
vector<array<int, 2>> in(x + 1, { -1, -1 }), out(x + 1, { -1, -1 });
int cloc = 0;
queue<int> q;
for (int i = 0; i <= x; ++i) {
if (i + b <= x) out[i + b][0] = i, in[i][0] = i + b;
if (i - a >= 0) out[i - a][1] = i, in[i][1] = i - a;
if (in[i][0] == -1 && in[i][1] == -1) q.push(i);
}
while (!q.empty()) {
int u = q.front(), v;
q.pop();
val[u] = ++cloc;
if (out[u][0] != -1) {
v = out[u][0];
in[u][0] = out[u][0] = -1;
if (in[v][1] == -1) q.push(v);
}
if (out[u][1] != -1) {
v = out[u][1];
in[v][1] = out[u][1] = -1;
if (in[v][0] == -1) q.push(v);
}
}
if (cloc != x + 1) return {};
for (int i = 1; i <= x; ++i)
ret.push_back(val[i] - val[i - 1]);
return ret;
}
int main() {
cin >> a >> b;
int l = 0, r = 1000000;
while (l < r) {
int mid = (l + r) >> 1;
if (l == r - 1) mid = r;
if (check(mid).size()) l = mid;
else r = mid - 1;
}
auto z = check(l);
printf("%d\n", l);
for (auto g : z) printf("%d ", g);
return 0;
}
编译信息
/sandbox/1/a.cpp:6:1: error: extended character is not valid in an identifier
6 | �� vector<int> ret, val(x + 1);
| ^
/sandbox/1/a.cpp:6:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:7:1: error: extended character is not valid in an identifier
7 | �� vector<array<int,2>> in(x + 1, {-1, -1}), out(x + 1, {-1, -1});
| ^
/sandbox/1/a.cpp:7:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:8:1: error: extended character is not valid in an identifier
8 | �� int cloc = 0;
| ^
/sandbox/1/a.cpp:8:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:9:1: error: extended character is not valid in an identifier
9 | �� queue<int> q;
| ^
/sandbox/1/a.cpp:9:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:10:1: error: extended character is not valid in an identifier
10 | �� for(int i = 0; i <= x; ++i) {
| ^
/sandbox/1/a.cpp:10:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:11:1: error: extended character is not valid in an identifier
11 | �� if(i + b <= x) out[i + b][0] = i, in[i][0] = i + b;
| ^
/sandbox/1/a.cpp:11:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:11:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:11:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:12:1: error: extended character is not valid in an identifier
12 | �� if(i - a >= 0) out[i - a][1] = i, in[i][1] = i - a;
| ^
/sandbox/1/a.cpp:12:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:12:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:12:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:12:24: error: extended character is not valid in an identifier
12 | if(i - a >= 0) ��out[i - a][1] = i, in[i][1] = i - a;
| ^
/sandbox/1/a.cpp:13:1: error: extended character is not valid in an identifier
13 | �� if(in[i][0] == -1 && in[i][1] == -1) q.push(i);
| ^
/sandbox/1/a.cpp:13:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:13:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:13:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:14:1: error: extended character is not valid in an identifier
14 | ��}
| ^
/sandbox/1/a.cpp:15:1: error: extended character is not valid in an identifier
15 | �� while(!q.empty()) {
| ^
/sandbox/1/a.cpp:15:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:16:1: error: extended character is not valid in an identifier
16 | �� int u = q.front(), v; q.pop();
| ^
/sandbox/1/a.cpp:16:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:16:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:16:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:17:1: error: extended character is not valid in an identifier
17 | �� val[u] = ++cloc;
| ^
/sandbox/1/a.cpp:17:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:17:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:17:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:18:1: error: extended character is not valid in an identifier
18 | �� if(out[u][0] != -1) {
| ^
/sandbox/1/a.cpp:18:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:18:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:18:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:19:1: error: extended character is not valid in an identifier
19 | �� v = out[u][0];
| ^
/sandbox/1/a.cpp:19:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:19:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:19:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:19:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:19:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:20:1: error: extended character is not valid in an identifier
20 | �� in[u][0] = out[u][0] = -1;
| ^
/sandbox/1/a.cpp:20:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:20:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:20:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:20:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:20:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:21:1: error: extended character is not valid in an identifier
21 | �� if(in[v][1] == -1) q.push(v);
| ^
/sandbox/1/a.cpp:21:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:21:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:21:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:21:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:21:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:22:1: error: extended character is not valid in an identifier
22 | �� }
| ^
/sandbox/1/a.cpp:22:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:22:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:23:1: error: extended character is not valid in an identifier
23 | �� if(out[u][1] != -1) {
| ^
/sandbox/1/a.cpp:23:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:23:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:23:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:24:1: error: extended character is not valid in an identifier
24 | �� v = out[u][1];
| ^
/sandbox/1/a.cpp:24:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:24:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:24:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:24:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:24:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:25:1: error: extended character is not valid in an identifier
25 | �� in[v][1] = out[u][1] = -1;
| ^
/sandbox/1/a.cpp:25:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:25:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:25:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:25:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:25:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:26:1: error: extended character is not valid in an identifier
26 | �� if(in[v][0] == -1) q.push(v);
| ^
/sandbox/1/a.cpp:26:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:26:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:26:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:26:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:26:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:27:1: error: extended character is not valid in an identifier
27 | �� }
| ^
/sandbox/1/a.cpp:27:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:27:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:28:1: error: extended character is not valid in an identifier
28 | ��}
| ^
/sandbox/1/a.cpp:29:1: error: extended character is not valid in an identifier
29 | �� if(cloc != x + 1) return {};
| ^
/sandbox/1/a.cpp:29:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:30:1: error: extended character is not valid in an identifier
30 | �� for(int i = 1; i <= x; ++i)
| ^
/sandbox/1/a.cpp:30:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:31:1: error: extended character is not valid in an identifier
31 | �� ret.push_back(val[i] - val[i - 1]);
| ^
/sandbox/1/a.cpp:31:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:31:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:31:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:32:1: error: extended character is not valid in an identifier
32 | �� return ret;
| ^
/sandbox/1/a.cpp:32:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:35:1: error: extended character is not valid in an identifier
35 | �� cin >> a >> b;
| ^
/sandbox/1/a.cpp:35:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:36:1: error: extended character is not valid in an identifier
36 | �� int l = 0, r = 1000000;
| ^
/sandbox/1/a.cpp:36:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:37:1: error: extended character is not valid in an identifier
37 | �� while(l < r) {
| ^
/sandbox/1/a.cpp:37:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:38:1: error: extended character is not valid in an identifier
38 | �� int mid = (l + r) >> 1;
| ^
/sandbox/1/a.cpp:38:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:38:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:38:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:39:1: error: extended character is not valid in an identifier
39 | �� if(l == r - 1) mid = r;
| ^
/sandbox/1/a.cpp:39:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:39:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:39:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:40:1: error: extended character is not valid in an identifier
40 | �� if(check(mid).size()) l = mid;
| ^
/sandbox/1/a.cpp:40:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:40:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:40:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:41:1: error: extended character is not valid in an identifier
41 | �� else r = mid - 1;
| ^
/sandbox/1/a.cpp:41:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:41:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:41:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:42:1: error: extended character is not valid in an identifier
42 | ��}
| ^
/sandbox/1/a.cpp:43:1: error: extended character is not valid in an identifier
43 | �� auto z = check(l);
| ^
/sandbox/1/a.cpp:43:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:44:1: error: extended character is not valid in an identifier
44 | �� printf("%d\n", l);
| ^
/sandbox/1/a.cpp:44:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:45:1: error: extended character is not valid in an identifier
45 | �� for(auto g : z) printf("%d ", g);
| ^
/sandbox/1/a.cpp:45:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp:46:1: error: extended character is not valid in an identifier
46 | �� return 0;
| ^
/sandbox/1/a.cpp:46:1: error: extended character is not valid in an identifier
/sandbox/1/a.cpp: In function 'std::vector<int> check(int)':
/sandbox/1/a.cpp:6:1: error: '\U000000a0\U000000a0vector' was not declared in this scope
6 | vector<int> ret, val(x + 1);
| ^~~~~~~~
/sandbox/1/a.cpp:6:12: error: expected primary-expression before 'int'
6 | vector<int> ret, val(x + 1);
| ^~~
/sandbox/1/a.cpp:7:12: error: 'array' was not declared in this scope
7 | vector<array<int,2>> in(x + 1, {-1, -1}), out(x + 1, {-1, -1});
| ^~~~~
/sandbox/1/a.cpp:7:12: note: 'std::array' is only available from C++11 onwards
/sandbox/1/a.cpp:7:18: error: expected primary-expression before 'int'
7 | vector<array<int,2>> in(x + 1, {-1, -1}), out(x + 1, {-1, -1});
| ^~~
/sandbox/1/a.cpp:7:44: error: expected primary-expression before ')' token
7 | vector<array<int,2>> in(x + 1, {-1, -1}), out(x + 1, {-1, -1});
| ^
/sandbox/1/a.cpp:7:66: error: expected primary-expression before ')' token
7 | vector<array<int,2>> in(x + 1, {-1, -1}), out(x + 1, {-1, -1});
| ^
/sandbox/1/a.cpp:8:1: error: '\U000000a0\U000000a0int' was not declared in this scope
8 | int cloc = 0;
| ^~~~~
/sandbox/1/a.cpp:9:1: error: '\U000000a0\U000000a0queue' was not declared in this scope
9 | queue<int> q;
| ^~~~~~~
/sandbox/1/a.cpp:9:11: error: expected primary-expression before 'int'
9 | queue<int> q;
| ^~~
/sandbox/1/a.cpp:10:9: error: expected primary-expression before 'int'
10 | for(int i = 0; i <= x; ++i) {
| ^~~
/sandbox/1/a.cpp:10:20: error: 'i' was not declared in this scope
10 | for(int i = 0; i <= x; ++i) {
| ^
/sandbox/1/a.cpp:15:12: error: 'q' was not declared in this scope
15 | while(!q.empty()) {
| ^
/sandbox/1/a.cpp:15:1: error: '\U000000a0\U000000a0while' was not declared in this scope
15 | while(!q.empty()) {
| ^~~~~~~
/sandbox/1/a.cpp:29:8: error: 'cloc' was not declared in this scope; did you mean 'clock'?
29 | if(cloc != x + 1) return {};
| ^~~~
| clock
/sandbox/1/a.cpp:29:1: error: '\U000000a0\U000000a0if' was not declared in this scope
29 | if(cloc != x + 1) return {};
| ^~~~
/sandbox/1/a.cpp:30:9: error: expected primary-expression before 'int'
30 | for(int i = 1; i <= x; ++i)
| ^~~
/sandbox/1/a.cpp:32:1: error: '\U000000a0\U000000a0return' was not declared in this scope
32 | return ret;
| ^~~~~~~~
/sandbox/1/a.cpp:33:1: warning: no return statement in function returning non-void [-Wreturn-type]
33 | }
| ^
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:35:1: error: '\U000000a0\U000000a0cin' was not declared in this scope
35 | cin >> a >> b;
| ^~~~~
/sandbox/1/a.cpp:36:1: error: '\U000000a0\U000000a0int' was not declared in this scope
36 | int l = 0, r = 1000000;
| ^~~~~
/sandbox/1/a.cpp:37:11: error: 'l' was not declared in this scope
37 | while(l < r) {
| ^
/sandbox/1/a.cpp:37:15: error: 'r' was not declared in this scope
37 | while(l < r) {
| ^
/sandbox/1/a.cpp:37:1: error: '\U000000a0\U000000a0while' was not declared in this scope
37 | while(l < r) {
| ^~~~~~~
/sandbox/1/a.cpp:43:1: error: '\U000000a0\U000000a0auto' was not declared in this scope
43 | auto z = check(l);
| ^~~~~~
/sandbox/1/a.cpp:44:1: error: '\U000000a0\U000000a0printf' was not declared in this scope
44 | printf("%d\n", l);
| ^~~~~~~~
/sandbox/1/a.cpp:45:8: warning: C++11 auto only available with '-std=c++11' or '-std=gnu++11'
45 | for(auto g : z) printf("%d ", g);
| ^
/sandbox/1/a.cpp:45:9: error: expected primary-expression before 'auto'
45 | for(auto g : z) printf("%d ", g);
| ^~~~
/sandbox/1/a.cpp:45:1: error: '\U000000a0\U000000a0for' was not declared in this scope
45 | for(auto g : z) printf("%d ", g);
| ^~~~~
/sandbox/1/a.cpp:46:1: error: '\U000000a0\U000000a0return' was not declared in this scope
46 | return 0;
| ^~~~~~~~