Submission #1226645

#TimeUsernameProblemLanguageResultExecution timeMemory
1226645ssafarovMinerals (JOI19_minerals)C++20
Compilation error
0 ms0 KiB
int lst;
int op[100000] = {};
int ps[100000] = {};

void func(vector<int> v, bool ok){
	// cout << lst << " " << ok << en;
	// for(auto g : v) cout << g << " ";
	// cout << en;
	vector<int> v1, v2;
	int st = lst;
	int gps = v.size() / 2;
	if(v.size() == 2){
		Answer(v[0], v[1]);
		return;
	}
	if(ok){
		int sb = (gps + 1) / 2;
		for(auto g : v){
			int nw = lst;
			if(op[g]){
				if(sb){
					v1.push_back(g);
					sb--;
				}else{
					v2.push_back(g);
					nw = Query(g);
					ps[g] ^= 1;
				}
			}else{
				nw = Query(g);
				if(ps[g]){
					if(nw == lst){
						v1.push_back(g);
					}else{
						v2.push_back(g);
					}
				}else{
					if(nw != lst){
						v1.push_back(g);
					}else{
						v2.push_back(g);
					}
				}
				ps[g] ^= 1;
			}
			lst = nw;
		}
	}else{
		int sb = (gps + 1) / 2;
		for(auto g : v){
			int nw = lst;
			if(op[g]){
				if(sb){
					v1.push_back(g);
					sb--;
				}else{
					v2.push_back(g);
					nw = Query(g);
					ps[g] ^= 1;
				}
			}else{
				nw = Query(g);
				if(ps[v[0]]){
					if(nw == lst){
						v1.push_back(g);
					}else{
						v2.push_back(g);
					}
				}else{
					if(nw != lst){
						v1.push_back(g);
					}else{
						v2.push_back(g);
					}
				}
				ps[g] ^= 1;
			}
			lst = nw;
		}
	}
	func(v1, !ok);
	func(v2, ok);
}

void Solve(int n){
	for(int i = 1; i <= 2 * n; ++i){
		int nw = Query(i);
		ps[i] = 1;
		if(nw != lst) op[i] = 1;
		lst = nw;
	}
	vector<int> v;
	for(int i = 1; i <= 2 * n; ++i){
		v.push_back(i);
	}
	func(v, 1);
}

Compilation message (stderr)

minerals.cpp:5:6: error: variable or field 'func' declared void
    5 | void func(vector<int> v, bool ok){
      |      ^~~~
minerals.cpp:5:11: error: 'vector' was not declared in this scope
    5 | void func(vector<int> v, bool ok){
      |           ^~~~~~
minerals.cpp:5:18: error: expected primary-expression before 'int'
    5 | void func(vector<int> v, bool ok){
      |                  ^~~
minerals.cpp:5:26: error: expected primary-expression before 'bool'
    5 | void func(vector<int> v, bool ok){
      |                          ^~~~
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:87:26: error: 'Query' was not declared in this scope
   87 |                 int nw = Query(i);
      |                          ^~~~~
minerals.cpp:92:9: error: 'vector' was not declared in this scope
   92 |         vector<int> v;
      |         ^~~~~~
minerals.cpp:92:16: error: expected primary-expression before 'int'
   92 |         vector<int> v;
      |                ^~~
minerals.cpp:94:17: error: 'v' was not declared in this scope
   94 |                 v.push_back(i);
      |                 ^
minerals.cpp:96:14: error: 'v' was not declared in this scope
   96 |         func(v, 1);
      |              ^
minerals.cpp:96:9: error: 'func' was not declared in this scope
   96 |         func(v, 1);
      |         ^~~~