結果
問題 | No.282 おもりと天秤(2) |
ユーザー |
![]() |
提出日時 | 2015-09-18 23:55:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 695 bytes |
コンパイル時間 | 558 ms |
コンパイル使用メモリ | 48,676 KB |
実行使用メモリ | 25,220 KB |
平均クエリ数 | 117.79 |
最終ジャッジ日時 | 2024-07-16 06:00:23 |
合計ジャッジ時間 | 11,474 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 TLE * 1 -- * 12 |
コンパイルメッセージ
main.cpp: In function ‘int cmp(const void*, const void*)’: main.cpp:16:14: warning: ignoring return value of ‘char* fgets(char*, int, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | fgets(buf, 3000, stdin); | ~~~~~^~~~~~~~~~~~~~~~~~ main.cpp: In function ‘int main()’: main.cpp:23:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 23 | scanf("%d%*c", &n); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <cstdio> #include <cstdlib> #include <vector> #include <string> 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(){ 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; } qsort(&v[0], n, sizeof(int), cmp); putchar('!'); for(int i = 0; i < n; ++i){ printf(" %d", v[i]); } puts(""); }