結果
問題 | No.594 壊れた宝物発見機 |
ユーザー |
|
提出日時 | 2017-11-19 21:12:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 780 bytes |
コンパイル時間 | 253 ms |
コンパイル使用メモリ | 42,112 KB |
最終ジャッジ日時 | 2024-11-14 20:15:35 |
合計ジャッジ時間 | 626 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int Q(const std::vector<int>&)': main.cpp:20:9: error: 'printf' was not declared in this scope 20 | printf("?"); | ^~~~~~ main.cpp:3:1: note: 'printf' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'? 2 | #include <vector> +++ |+#include <cstdio> 3 | main.cpp:22:9: error: 'puts' was not declared in this scope 22 | puts(""); | ^~~~ main.cpp:23:16: error: 'stdout' was not declared in this scope 23 | fflush(stdout); | ^~~~~~ main.cpp:23:16: note: 'stdout' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'? main.cpp:23:9: error: 'fflush' was not declared in this scope 23 | fflush(stdout); | ^~~~~~ main.cpp:25:9: error: 'scanf' was not declared in this scope 25 | scanf("%d",&n); | ^~~~~ main.cpp: In function 'int main()': main.cpp:36:9: error: 'printf' was not declared in this scope 36 | printf("!"); | ^~~~~~ main.cpp:36:9: note: 'printf' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'? main.cpp:38:9: error: 'puts' was not declared in this scope 38 | puts(""); | ^~~~
ソースコード
#include <functional>#include <vector>template<typename T,typename F=std::function<bool(T)>>T ternarysearch(T lo,T hi,const T eps,const F &predicate){for(;lo+eps<hi;){T mi=(lo+hi)/2;if(predicate(mi)>predicate(mi-1)){hi=mi;}else{lo=mi;}}return lo;}template<typename T,typename F=std::function<bool(T)>>T ternarysearch(T lo,T hi,const F &predicate){return ternarysearch(lo,hi,(T)1,predicate);}int Q(const std::vector<int>&v){printf("?");for(auto &e:v)printf(" %d",e);puts("");fflush(stdout);int n;scanf("%d",&n);return n;}int main(){std::vector<int>v(3);for(int i=0;i<3;i++)v[i]=ternarysearch(-150,151,[&](int n){std::vector<int>a(3);a[i]=n;return Q(a);});printf("!");for(auto &e:v)printf(" %d",e);puts("");}