結果
| 問題 |
No.2252 Find Zero
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-24 22:02:55 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 64 ms / 2,000 ms |
| コード長 | 1,193 bytes |
| コンパイル時間 | 558 ms |
| コンパイル使用メモリ | 86,780 KB |
| 最終ジャッジ日時 | 2025-02-11 17:18:54 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
32 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:50:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
50 | scanf("%d", &k);
| ~~~~~^~~~~~~~~~
ソースコード
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;
bool rcmp(int a, int b) { return a>b; }
typedef long long LL;
class mypcmp {
public:
bool operator()(const int& a, const int& b) {
return a<b;
}
};
char mk[1004];
int pp[32];
int main() {
int n, i, j, v, p, k, a, b;
scanf("%d", &n);
p=-1;
for (i=0; i<n; i++) mk[i]=0;
i=0; while(1) {
if (p==-1) {
while(i<n&&mk[i]) i++;
a=i++;
while(i<n&&mk[i]) i++;
if (i>=n) { p=a; break; }
b=i++;
} else {
while(i<n&&mk[i]) i++;
if (i>=n) break;
a=i++;
b=p;
}
mk[a]=1; mk[b]=1;
printf("? %d %d\n", a, b); fflush(stdout);
scanf("%d", &k);
if (k==a) { p=b; break; }
if (k==b) { p=a; break; }
if (mk[k]) p=-1;
else { p=k; mk[k]=1; }
}
printf("! %d\n", p);
fflush(stdout);
return 0;
}