Submission #499565

# Submission time Handle Problem Language Result Execution time Memory
499565 2021-12-28T16:37:50 Z MateGiorbelidze Cave (IOI13_cave) C++14
0 / 100
2 ms 436 KB
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define sc second
#define ff first
#define pb push_back
#define in insert

void exploreCave(int N) {
    int s[N+1],d[N+1],used[N+1],ans=0,sl=0,val=1,swp=0;
    for (int i=1; i<=N; i++) {
    	d[i]=-1;
    	s[i]=1;
    	used[i] = 0;
	}
    while (ans!=-1) {
    	
    	ans=tryCombination(s);
    	
    	for (int i=sl; i<ans; i++) {
    		
    		ll l=0,r=N-1;
    		
    		while (l < r) {
    			ll mid = ( l + r + 1 ) / 2;
    			
    			for (int j = mid; j < N; j ++ ) {
    				
    				if (used[j] == 0) s[j] = swp;
    				
				}
    			
    			ll cur = tryCombination(s);
    			
    			for (int j = mid; j < N; j ++ ) {
    				
    				if (used[j] == 0) s[j] = val;
    				
				}
    			
    			if (cur != ans) {
    				r = mid - 1;
				}
				else l = mid;
				
			}
			
			used[l] = 1;
			
			s [l] = val ;
			
			d [l] = i;
			
		}
		
    	if (val == 1) {
    		val = 0;
    		swp = 1;
		}
		else {
			val = 1;
			swp = 0;
		}
    	
    	sl = ans ;
    	
	}
	answer(s,d);
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB too much calls on tryCombination()
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 436 KB too much calls on tryCombination()
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB too much calls on tryCombination()
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB too much calls on tryCombination()
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB too much calls on tryCombination()
2 Halted 0 ms 0 KB -