結果
| 問題 |
No.513 宝探し2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-12 18:03:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,154 bytes |
| コンパイル時間 | 1,612 ms |
| コンパイル使用メモリ | 174,136 KB |
| 実行使用メモリ | 827,480 KB |
| 最終ジャッジ日時 | 2024-07-16 13:39:12 |
| 合計ジャッジ時間 | 6,110 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | MLE * 1 -- * 11 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:40:18: warning: 'd' may be used uninitialized [-Wmaybe-uninitialized]
40 | int d = ask( d, t );
| ~~~^~~~~~~~
main.cpp:40:11: note: 'd' was declared here
40 | int d = ask( d, t );
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
int ask( int x, int t ) {
static map< int, int > memo[ 2 ];
if( memo[ t ].count( x ) ) {
return memo[ t ][ x ];
}
memo[ t ][ x ] = t == 0 ? ask( x, 0 ) : ask( 0, x );
if( memo[ t ][ x ] == 0 ) {
exit( 0 );
}
return memo[ t ][ x ];
}
signed main() {
ios::sync_with_stdio( 0 );
int ans[ 2 ];
for( int t = 0; t < 2; ++t ) {
int lb = 0, ub = int( 1e5 );
while( ub - lb > 5 ) {
int f = lb + ( ub - lb ) / 3;
int g = lb + ( ub - lb ) * 2 / 3;
int a = ask( lb, t );
int b = ask( f, t );
int c = ask( g, t );
int d = ask( ub, t );
if( a <= b and b <= c and c <= d ) {
ub = f;
} else if( a >= b and b <= c and c <= d ) {
ub = g;
} else if( a >= b and b >= c and c <= d ) {
lb = f;
} else {
lb = g;
}
}
int mind = int( 1e5 );
for( int i = lb; i <= ub; ++i ) {
int d = ask( d, t );
if( d < mind ) {
mind = d;
ans[ t ] = i;
}
}
}
cout << ans[ 0 ] << " " << ans[ 1 ] << endl;
int d;
cin >> d;
assert( d == 0 );
return 0;
}