#include "coloring.h"
#include <vector>
using namespace std;
bool in[101];
vector<int> v1, v2;
int find(int back, int &coin) {
if (!coin) return -1;
for (auto x : v1) Color(x);
int c = GetColor(back); --coin;
vector<int> *live = &v1, *erase = &v2;
if (c) live = &v2, erase = &v1;
if (live->size() == 1) return live->back();
erase->clear();
while (live->size() > erase->size()) {
erase->push_back(live->back());
live->pop_back();
}
return find(back, coin);
}
void ColoringSame(int N) {
int i;
int coin = 200;
vector<int> stk,v;
stk.push_back(1);
while (coin && stk.size() != N) {
int t = 1;
v1.clear(); v2.clear();
for (i = 2; i <= N; ++i) {
if (in[i]) continue;
if (t) v1.push_back(i);
else v2.push_back(i);
t = 1 - t;
}
int back = find(stk.back(), coin);
if (back > 0) {
in[back] = 1;
stk.push_back(back);
}
}
for (Color(1),i = 2; i <= N; ++i) if (!in[i]) v.push_back(i);
for (i = 0; i < v.size(); ++i) for (auto x : v) Color(x);
for (; stk.size() > 1; stk.pop_back()) Color(stk.back());
}
Compilation message
coloring.cpp: In function 'void ColoringSame(int)':
coloring.cpp:25:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while (coin && stk.size() != N) {
~~~~~~~~~~~^~~~
coloring.cpp:41:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < v.size(); ++i) for (auto x : v) Color(x);
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
3 ms |
432 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
3 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
3 ms |
256 KB |
Output is correct |
16 |
Runtime error |
2 ms |
256 KB |
Execution failed because the return code was nonzero |
17 |
Halted |
0 ms |
0 KB |
- |