답안 #706264

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
706264 2023-03-06T08:18:12 Z vjudge1 Nizovi (COI14_nizovi) C++17
60 / 100
859 ms 328 KB
#include <bits/stdc++.h>
#include <array>
#define all(v) (v.begin()), (v.end())
#define setall(a, val) for(auto& x : a) x = val
#define ll long long
clock_t start_time;
double get_time() { return (double)(clock() - start_time) / CLOCKS_PER_SEC; }
void init() {
#ifndef ONLINE_JUDGE:
	FILE* _ = freopen("in.txt", "r", stdin);
	start_time = clock();
#endif
}
const ll MOD = 1e9 + 7;
const ll N = 5e3 + 7;
const ll M = 1e2 + 7;
using namespace std;
//####################################################################################

int main() {
	//ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); srand(time(0)); init();

	int a, b;
	cin >> a >> b;
	int n = a + b;
	
	for (int i = a + 1; i <= n; i++) {
		int l = 1, r = i - 1, idx = -1;
		while (l <= r) {
			int m = (l + r) / 2;
			cout << "cmp " << i << ' ' << m << endl;
			int x;
			cin >> x;
			if (x == 0) {
				idx = m;
				break;
			}
			if (x == 1)
				l = m + 1, idx = m;
			else
				r = m - 1;
		}
		idx++;

		if (idx != 0) {
			if(idx < i)
				cout << "reverse " << idx << ' ' << i << endl;
			if(idx + 1 < i)
				cout << "reverse " << idx + 1 << ' ' << i << endl;
		}
	}
	cout << "end" << endl;

	cerr << get_time() << "s" << endl;
}

Compilation message

nizovi.cpp:9:21: warning: extra tokens at end of #ifndef directive
    9 | #ifndef ONLINE_JUDGE:
      |                     ^
nizovi.cpp: In function 'void init()':
nizovi.cpp:10:8: warning: unused variable '_' [-Wunused-variable]
   10 |  FILE* _ = freopen("in.txt", "r", stdin);
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 3 ms 300 KB Output is correct
3 Correct 3 ms 208 KB Output is correct
4 Correct 36 ms 276 KB Output is correct
5 Correct 47 ms 276 KB Output is correct
6 Correct 34 ms 328 KB Output is correct
7 Runtime error 134 ms 284 KB Execution killed with signal 13
8 Runtime error 859 ms 280 KB Execution killed with signal 13
9 Runtime error 118 ms 276 KB Execution killed with signal 13
10 Runtime error 91 ms 280 KB Execution killed with signal 13