結果
問題 |
No.355 数当てゲーム(2)
|
ユーザー |
|
提出日時 | 2016-05-17 16:12:38 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 1,209 bytes |
コンパイル時間 | 788 ms |
コンパイル使用メモリ | 58,124 KB |
実行使用メモリ | 25,488 KB |
平均クエリ数 | 5.52 |
最終ジャッジ日時 | 2024-07-16 23:43:40 |
合計ジャッジ時間 | 4,620 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 52 |
ソースコード
#include <iostream> #include <list> using namespace std; list<int*> pt; void est(const int o[], const int n[], int& x, int& y) { x = y = 0; for ( int i = 0; i < 4; i++ ) { if ( o[i] == n[i] ) { x++; } else { for ( int j = 0; j < 4; j++ ) { if ( o[i] == n[j] ) { y++; break; } } } } } void io(int n[], int& x, int& y) { cout << n[0] << " " << n[1] << " " << n[2] << " " << n[3] << endl; cin >> x >> y; } int main() { for ( int i = 0; i < 10; i++ ) { for ( int j = 0; j < 10; j++ ) { if ( i == j ) continue; for ( int k = 0; k < 10; k++ ) { if ( i == k || j == k ) continue; for ( int l = 0; l < 10; l++ ) { if ( i == l || j == l || k == l ) continue; int* n = new int[4] { i, j, k, l }; pt.push_back(n); } } } } for ( ;; ) { int x, y; auto it = pt.begin(); int n[] = { (*it)[0], (*it)[1], (*it)[2], (*it)[3] }; io(n, x, y); if ( x == 4 ) { break; } do { int xt, yt; int o[] = { (*it)[0], (*it)[1], (*it)[2], (*it)[3] }; est(*it, n, xt, yt); auto t_it = it++; if ( x != xt || y != yt ) { pt.erase(t_it); } else { int a = 0; } } while ( it != pt.end() ); } return 0; }