結果

問題 No.1187 皇帝ペンギン
ユーザー tokutoku
提出日時 2020-09-05 01:34:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 1,000 ms
コード長 2,082 bytes
コンパイル時間 1,292 ms
コンパイル使用メモリ 166,376 KB
実行使用メモリ 24,492 KB
平均クエリ数 17.50
最終ジャッジ日時 2023-09-24 06:36:07
合計ジャッジ時間 4,923 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
23,412 KB
testcase_01 AC 20 ms
23,604 KB
testcase_02 AC 21 ms
24,276 KB
testcase_03 AC 20 ms
24,456 KB
testcase_04 AC 22 ms
23,340 KB
testcase_05 AC 20 ms
23,196 KB
testcase_06 AC 19 ms
24,060 KB
testcase_07 AC 20 ms
23,688 KB
testcase_08 AC 20 ms
24,072 KB
testcase_09 AC 21 ms
23,580 KB
testcase_10 AC 21 ms
24,360 KB
testcase_11 AC 19 ms
23,328 KB
testcase_12 AC 19 ms
23,988 KB
testcase_13 AC 22 ms
23,496 KB
testcase_14 AC 19 ms
23,772 KB
testcase_15 AC 19 ms
24,348 KB
testcase_16 AC 19 ms
23,424 KB
testcase_17 AC 19 ms
24,348 KB
testcase_18 AC 20 ms
23,424 KB
testcase_19 AC 19 ms
24,000 KB
testcase_20 AC 19 ms
23,880 KB
testcase_21 AC 18 ms
24,492 KB
testcase_22 AC 19 ms
24,324 KB
testcase_23 AC 20 ms
23,208 KB
testcase_24 AC 19 ms
24,024 KB
testcase_25 AC 19 ms
23,868 KB
testcase_26 AC 19 ms
24,072 KB
testcase_27 AC 19 ms
24,300 KB
testcase_28 AC 18 ms
24,060 KB
testcase_29 AC 20 ms
24,240 KB
testcase_30 AC 20 ms
23,340 KB
testcase_31 AC 23 ms
23,592 KB
testcase_32 AC 20 ms
24,228 KB
testcase_33 AC 19 ms
23,592 KB
testcase_34 AC 19 ms
23,856 KB
testcase_35 AC 19 ms
23,568 KB
testcase_36 AC 20 ms
24,456 KB
testcase_37 AC 20 ms
24,300 KB
testcase_38 AC 19 ms
23,460 KB
testcase_39 AC 19 ms
23,448 KB
testcase_40 AC 19 ms
23,400 KB
testcase_41 AC 20 ms
24,180 KB
testcase_42 AC 19 ms
24,348 KB
testcase_43 AC 21 ms
23,340 KB
testcase_44 AC 21 ms
23,376 KB
testcase_45 AC 19 ms
23,568 KB
testcase_46 AC 19 ms
23,412 KB
testcase_47 AC 19 ms
23,784 KB
testcase_48 AC 19 ms
23,868 KB
testcase_49 AC 19 ms
24,468 KB
testcase_50 AC 22 ms
23,616 KB
testcase_51 AC 20 ms
23,412 KB
testcase_52 AC 20 ms
24,492 KB
testcase_53 AC 19 ms
23,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;

const int MAX = 1010000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


int main(){

	int ok = 1001;
	int ng = -1;

	while (ok - ng > 1) {
		int mid = (ok + ng) / 2;
		string s;
		cout << "? " << mid << endl;
		cin >> s;
		if (s == "safe") {
			ng = mid;
			continue;
		}

		cout << "? " << mid + 1 << endl;
		cin >> s;
		if (s == "safe") {
			ng = mid + 1;
		}
		else {
			ok = mid;
		}
	}
	cout << "? " << ok << endl;
	string s;
	cin >> s;
	if (s == "safe") {
		cout << "! " << ok << endl;
	}
	else cout << "! " << ng << endl;
}
0