Submission #55873

# Submission time Handle Problem Language Result Execution time Memory
55873 2018-07-09T06:30:24 Z leejseo Hotter Colder (IOI10_hottercolder) C++
0 / 100
1820 ms 262148 KB
#include "grader.h"

int HC(int N){
	int lo = 1, hi = N, from=-1;
	while (lo < hi){
		int m1 = (2*lo + hi)/3;
		int m2 = (lo + 2*hi)/3;

		if (hi == lo + 1){
			HC(lo);
			if (HC(hi) == 1) return hi;
			return lo;
		}

		if (hi == lo + 2){
			HC(lo);
			int val = HC(hi);
			if (val == 0) return lo + hi >> 1;
			if (val == 1) return hi;
			return lo;
		}

		if (from == -1){
			HC(lo);
			int v1 = HC(m1);
			if (v1 == -1){
				hi = m1;
				from = 1; // right
				continue;
			}
			if (v1 == 0) return (lo + m1) >> 1;
			lo = m1;
			from = 0;
			continue;
		}
		if (from){
			int v2 = HC(m2);
			if (v2 == 0) return (m2 + hi) >> 1;
			if (v2 == -1){
				lo = m2;
				from = 0;
				continue;
			}
			hi = m2;
			from = 1;
			continue;
		}
		int v1 = HC(m1);
		if (v1 == 0) return (lo + m1) >> 1;
		if (v1 == -1){
			hi = m1;
			from = 1;
			continue;
		}
		lo = m1;
		from = 0;
		continue;
	}	
	return lo;
}

Compilation message

hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:18:28: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    if (val == 0) return lo + hi >> 1;
                         ~~~^~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1820 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 597 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 178 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 536 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)