Submission #108693

# Submission time Handle Problem Language Result Execution time Memory
108693 2019-05-01T04:57:50 Z tjd229 1-Color Coloring (FXCUP2_coloring) C++14
0 / 1
4 ms 384 KB
#include "coloring.h"
#include <vector>
using namespace std;
int in[101];
void ColoringSame(int N){
	int i,j,coin=200;
	int pad[7] = { 0 };
	vector<int> bit_vec[7],stk,v;
	for (i = 2; i <= N; ++i) {
		for (int j = 0, n = i; j < 7; ++j) {
			if (n & 1) bit_vec[j].push_back(i);
			n >>= 1;
		}
	}
	stk.push_back(1);
	while (coin) {
		int nxt = 0;
		int back = stk.back();
		for (j = 0; j < 7 && coin; ++j) {
			if (bit_vec[j].size() - pad[j]) {
				for (auto x : bit_vec[j]) if(!in[x]) Color(x);
			}
			if (!GetColor(1)) nxt |= (1 << j);
			--coin;
		}
		if (j > 7) {
			stk.push_back(nxt);
			in[nxt] = 1;
			for (j = 0; j < 7; ++j) {
				if (nxt & 1) ++pad[j];
				nxt >>= 1;
			}
		}
	}
	Color(1);
	for (i = 2; i <= N; ++i) if (!in[i]) v.push_back(i);
	for (i = 0; i < v.size(); ++i) for (j = 0; j < v.size(); ++j) Color(v[j]);
	for (; stk.size() > 1; stk.pop_back()) Color(stk.back());
}

Compilation message

coloring.cpp: In function 'void ColoringSame(int)':
coloring.cpp:18:7: warning: unused variable 'back' [-Wunused-variable]
   int back = stk.back();
       ^~~~
coloring.cpp:37:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < v.size(); ++i) for (j = 0; j < v.size(); ++j) Color(v[j]);
              ~~^~~~~~~~~~
coloring.cpp:37:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < v.size(); ++i) for (j = 0; j < v.size(); ++j) Color(v[j]);
                                             ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Runtime error 2 ms 256 KB Execution failed because the return code was nonzero
14 Halted 0 ms 0 KB -