結果
| 問題 |
No.282 おもりと天秤(2)
|
| コンテスト | |
| ユーザー |
climpet
|
| 提出日時 | 2015-09-19 00:06:00 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 788 bytes |
| コンパイル時間 | 630 ms |
| コンパイル使用メモリ | 53,696 KB |
| 実行使用メモリ | 25,604 KB |
| 平均クエリ数 | 509.17 |
| 最終ジャッジ日時 | 2024-07-16 06:02:27 |
| 合計ジャッジ時間 | 10,709 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 3 TLE * 5 -- * 3 |
コンパイルメッセージ
main.cpp: In function ‘int cmp(const void*, const void*)’:
main.cpp:18:14: warning: ignoring return value of ‘char* fgets(char*, int, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | fgets(buf, 3000, stdin);
| ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:27:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | scanf("%d%*c", &n);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <ctime>
#include <algorithm>
using namespace std;
int n;
string rest;
char buf[3000];
int cmp(const void *p, const void *q){
int a = *static_cast<const int*>(p);
int b = *static_cast<const int*>(q);
printf("? %d %d%s", a, b, rest.c_str());
fflush(stdout);
fgets(buf, 3000, stdin);
if(buf[0] == '<'){ return -1; }
if(buf[0] == '>'){ return 1; }
return 0;
}
int main(){
srand(time(0));
scanf("%d%*c", &n);
for(int i = 1; i < n; ++i){
rest += " 0 0";
}
rest += '\n';
vector<int> v(n);
for(int i = 0; i < n; ++i){
v[i] = i + 1;
}
random_shuffle(v.begin(), v.end());
qsort(&v[0], n, sizeof(int), cmp);
putchar('!');
for(int i = 0; i < n; ++i){
printf(" %d", v[i]);
}
puts("");
}
climpet