Submission #332054

# Submission time Handle Problem Language Result Execution time Memory
332054 2020-12-01T09:49:09 Z shrek12357 Cave (IOI13_cave) C++14
0 / 100
579 ms 492 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
#include <stack>
#include <bitset>
#include "cave.h"
using namespace std;
#define ll long long
//cin.tie(0);ios_base::sync_with_stdio(0); 
 
const int MAXN = 5005;
int N;
 
/*void exploreCave(int n) {
	int pos[MAXN];
	int ans[MAXN];
	for (int i = 0; i < n; i++) {
		pos[i] = 0;
		ans[i] = i;
	}
	int cnt = 0;
	while (true) {
		int num = tryCombination(pos);
		if (num == -1) {
			break;
		}
		cnt = num;
		pos[num] = (pos[num] + 1) % 2;
	}
	answer(pos, ans);
}*/
 
/*void exploreCave(int n) {
	int pos[MAXN];
	int ans[MAXN];
	for (int i = 0; i < n; i++) {
		ans[i] = -1;
		pos[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		pos[i] = 1;
		ans[i] = tryCombination(pos);
		pos[i] = 0;
	}
	answer(pos, ans);
}*/
 
/*int tryCombination(int s[]) {
	for (int i = 0; i < N; i++) {
		cout << s[i] << endl;
	}
	int temp;
	cin >> temp;
	cout << endl;
	return temp;
}
 
void answer(int s[], int a[]) {
	for (int i = 0; i < N; i++) {
		cout << s[i] << endl;
	}
	for (int i = 0; i < N; i++) {
		cout << a[i] << endl;
	}
}*/
 
void exploreCave(int n) {
	N = n;
	int pos[MAXN];
	int ans[MAXN];
	for (int i = 0; i < n; i++) {
		pos[i] = 0;
		ans[i] = -1;
	}
	for (int i = 0; i < n; i++) {
		int lo = 0;
		int hi = n - 1;
		int cur = tryCombination(pos) == i;
		while (lo < hi) {
			int mid = (lo + hi) / 2;
			for (int j = lo; j <= mid; j++) {
				if (ans[j] == -1) {
					pos[j] = 1;
				}
			}
			int n1 = tryCombination(pos) == cur;
			if (n1) {
				hi = mid;
			}
			else {
				lo = mid + 1;
			}
			for (int j = 0; j <= mid; j++) {
				if (ans[j] == -1) {
					pos[j] = 0;
				}
			}
		}
		ans[lo] = i;
		pos[lo] = cur;
	}
	answer(pos, ans);
}
# Verdict Execution time Memory Grader output
1 Incorrect 189 ms 492 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 579 ms 492 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Answer is wrong
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Answer is wrong
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 189 ms 492 KB Answer is wrong
2 Halted 0 ms 0 KB -