結果
| 問題 |
No.305 鍵(2)
|
| コンテスト | |
| ユーザー |
hotpepsi
|
| 提出日時 | 2015-11-29 23:25:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 578 bytes |
| コンパイル時間 | 787 ms |
| コンパイル使用メモリ | 60,436 KB |
| 実行使用メモリ | 40,400 KB |
| 最終ジャッジ日時 | 2024-07-16 21:56:51 |
| 合計ジャッジ時間 | 7,324 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:21:64: warning: integer overflow in expression of type ‘int’ results in ‘-2147483648’ [-Woverflow]
21 | w[i] = '0' + (rand() * 10) / (RAND_MAX + 1);
| ^
main.cpp: In function ‘int getres(const char*)’:
main.cpp:12:14: warning: ignoring return value of ‘char* fgets(char*, int, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | fgets(buff, 1024, stdin);
| ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
using namespace std;
int getres(const char *w) {
printf("%s\n", w);
fflush(stdout);
char buff[1024];
fgets(buff, 1024, stdin);
return atoi(buff);
}
int main(int argc, char *argv[])
{
char w[16] = {};
while (true) {
for (int i = 0; i < 10; ++i) {
w[i] = '0' + (rand() * 10) / (RAND_MAX + 1);
}
if (getres(w) == 0) {
break;
}
}
for (int i = 0; i < 10; ++i) {
for (int j = 0; j < 10; ++j) {
w[i] = '0' + j;
if (getres(w) == i + 1) {
break;
}
}
}
return 0;
}
hotpepsi