Submission #386422

#TimeUsernameProblemLanguageResultExecution timeMemory
386422ismoilovCave (IOI13_cave)C++14
100 / 100
1126 ms764 KiB
#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(), (x).end()
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
#define fv(c) for(int (a) = (1); (a) <= (c); (a)++)
#define fz(c) for(int (a) = (0); (a) < (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
#define pb push_back
#define in insert
#define ss second
#define ff first

void exploreCave(int n) {
	int v[n], ans[n], a[n];
	vector <bool> s(n+1, 0);
	fp(i,0,n)
		a[i] = -1, v[i] = 0;
	/*for(auto it : s)
		cout << it << " ";*/
	int x = 0;
	fp(i,0,n){
		fp(j,0,n)
			if(!s[j])
				v[j] = x;
		int f = tryCombination(v);
		if(f == i)
			x = (x+1)%2;
		int l = 0, r = n-1, p = 0;
		while(l <= r){
			int m = (l+r)/2;
			fp(j,0,n){
				if(!s[j]){
					v[j] = x;
					if(j < l || j > m)
						v[j] = (x+1)%2;
				}
			}
			f = tryCombination(v);
			if(f == i)
				l = m + 1, p = m+1;
			else
				r = m - 1, p = l;
		}
		v[p] = x;
		s[p] = 1;
		ans[p] = x;
		a[p] = i;
		
	}
	answer(v, a);
    
}

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:10:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
cave.cpp:24:2: note: in expansion of macro 'fp'
   24 |  fp(i,0,n)
      |  ^~
cave.cpp:10:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
cave.cpp:29:2: note: in expansion of macro 'fp'
   29 |  fp(i,0,n){
      |  ^~
cave.cpp:10:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   10 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
cave.cpp:30:3: note: in expansion of macro 'fp'
   30 |   fp(j,0,n)
      |   ^~
cave.cpp:10:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   10 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
cave.cpp:39:4: note: in expansion of macro 'fp'
   39 |    fp(j,0,n){
      |    ^~
cave.cpp:22:12: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   22 |  int v[n], ans[n], a[n];
      |            ^~~
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...