結果

問題 No.355 数当てゲーム(2)
ユーザー tottoripaper
提出日時 2018-03-11 15:14:47
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 1,384 bytes
コンパイル時間 1,950 ms
コンパイル使用メモリ 172,308 KB
実行使用メモリ 25,580 KB
平均クエリ数 64.75
最終ジャッジ日時 2024-07-17 01:36:42
合計ジャッジ時間 6,634 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/functional:54,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:71,
                 from main.cpp:1:
In constructor 'constexpr std::_Head_base<_Idx, _Head, false>::_Head_base(_UHead&&) [with _UHead = int&; long unsigned int _Idx = 1; _Head = int]',
    inlined from 'constexpr std::_Tuple_impl<_Idx, _Head>::_Tuple_impl(_UHead&&) [with _UHead = int&; long unsigned int _Idx = 1; _Head = int]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/tuple:441:38,
    inlined from 'constexpr std::_Tuple_impl<_Idx, _Head, _Tail ...>::_Tuple_impl(_UHead&&, _UTail&& ...) [with _UHead = int&; _UTail = {int&}; <template-parameter-2-3> = void; long unsigned int _Idx = 0; _Head = int; _Tail = {int}]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/tuple:292:38,
    inlined from 'constexpr std::tuple<_T1, _T2>::tuple(_U1&&, _U2&&) [with _U1 = int&; _U2 = int&; typename std::enable_if<std::_TupleConstraints<(! __is_alloc_arg<_U1>()), _T1, _T2>::__is_implicitly_constructible<_U1, _U2>(), bool>::type <anonymous> = true; _T1 = int; _T2 = int]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/tuple:1079:63,
    inlined from 'constexpr std::tuple<typename std::__strip_reference_wrapper<typename std::decay<_Elements>::type>::__type ...> std::make_tuple(_Elements&& ...) [with _Elements = {int&, int&}]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/tuple:1581:62,
    inlined from 'P f(int, int)' at main.cpp:49:34:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/tuple:200:11: warning: 'x4' may be used uninitialized [-Wmaybe-uninitialized]
  200 |         : _M_head_impl(std::forward<_UHead>(__h)) { }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp: In function 'P f(int, int)':
main.cpp:30:13: note: 'x4' was declared here
   30 |     int x3,

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))
using ll = long long;
using P = std::tuple<int,int>;
using P4 = std::tuple<int,int,int,int>;
const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
P ask(int x1, int x2, int x3, int x4){
std::cout << x1 << " " << x2 << " " << x3 << " " << x4 << std::endl;
int a, b;
std::cin >> a >> b;
if(a == 4){
exit(0);
}
return std::make_tuple(a, b);
}
P f(int x1, int x2){
int x3, x4, mx = 0;
for(int i=0;i<10;++i){
for(int j=i+1;j<10;++j){
if(i == x1 || i == x2 || j == x1 || j == x2){
continue;
}
int s, t;
tie(s, t) = ask(x1, x2, i, j);
if(mx < s + t){
mx = s + t;
x3 = i;
x4 = j;
}
}
}
return std::make_tuple(x3, x4);
}
int main(){
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
int xs[4];
tie(xs[0], xs[1]) = f(0, 1);
tie(xs[2], xs[3]) = f(xs[0], xs[1]);
sort(xs, xs+4);
while(true){
ask(xs[0], xs[1], xs[2], xs[3]);
if(!next_permutation(xs, xs+4)){
break;
}
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0