/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <fstream>
#define mod 1000000000ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
using namespace std;
#ifndef death
#include "scales.h"
#endif
#ifdef death
int getHeaviest(int a, int b, int c)
{
cout << "? Heavy " << a << " " << b << " " << c << endl;
int res;
cin >> res;
return res;
}
int getMedian(int a, int b, int c)
{
cout << "? Median " << a << " " << b << " " << c << endl;
int res;
cin >> res;
return res;
}
int getLightest(int a, int b, int c)
{
cout << "? Light " << a << " " << b << " " << c << endl;
int res;
cin >> res;
return res;
}
int getNextLightest(int a, int b, int c, int d)
{
cout << "? Next " << a << " " << b << " " << c << " " << d << endl;
int res;
cin >> res;
return res;
}
void answer(int *a)
{
cout << "! ";
for (int i = 0; i < 6; i++)
cout << a[i] << " ";
cout << endl;
}
#endif
int n = 6;
void init(int T)
{
srand(64895);
}
void orderCoins()
{
vector<int> ind, l, r, ans;
for (int i = 1; i <= n; i++)
ind.PB(i);
random_shuffle(all(ind));
l.PB(getLightest(ind[0], ind[1], ind[2]));
l.PB(getMedian(ind[0], ind[1], ind[2]));
for (int i = 0; i < 3; i++)
if (ind[i] != l[0] && ind[i] != l[1])
l.PB(ind[i]);
r.PB(getLightest(ind[3], ind[4], ind[5]));
r.PB(getMedian(ind[3], ind[4], ind[5]));
for (int i = 3; i < n; i++)
if (ind[i] != r[0] && ind[i] != r[1])
r.PB(ind[i]);
reverse(all(l));
reverse(all(r));
ans.PB(getLightest(r.back(), l.back(), r[r.size() - 2]));
if (ans.back() == r.back())
r.pop_back();
else
l.pop_back();
if (l.size() < r.size())
swap(l, r);
while (!l.empty() || !r.empty())
{
if (l.empty())
{
ans.PB(r.back());
r.pop_back();
}
else if (r.empty())
{
ans.PB(l.back());
l.pop_back();
}
else
{
int res = 0;
res = getMedian(ans[0], r.back(), l.back());
if (res != r.back())
{
if (l.size() != 1)
{
if (l.size() == 3)
{
res = getNextLightest(l[0], l[1], l[2], r.back());
while (!l.empty() && l.back() != res)
{
ans.PB(l.back());
l.pop_back();
}
}
else
{
res = getMedian(ans[0], r.back(), l[1]);
if (res == l[1])
while (!l.empty())
{
ans.PB(l.back());
l.pop_back();
}
else
{
ans.PB(l.back());
l.pop_back();
}
}
}
else
{
ans.PB(l.back());
l.pop_back();
}
}
ans.PB(r.back());
r.pop_back();
}
}
int ANS[6];
for (int i = 0; i < n; i++)
ANS[i] = ans[i];
answer(ANS);
}
#ifdef death
int main()
{
int T;
cin >> T;
init(T);
while (T--)
{
orderCoins();
}
return 0;
}
#endif
/*
2 2 8
1 7
*/
Compilation message
scales.cpp: In function 'void init(int)':
scales.cpp:75:15: warning: unused parameter 'T' [-Wunused-parameter]
void init(int T)
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
128 KB |
Output isn't correct |
12 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
13 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
14 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
15 |
Incorrect |
2 ms |
252 KB |
Output isn't correct |
16 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
17 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
18 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
19 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
20 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
21 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
22 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
23 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
24 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
25 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
26 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
27 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
28 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
29 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
30 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
31 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
32 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
33 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
34 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
35 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
36 |
Incorrect |
2 ms |
300 KB |
Output isn't correct |
37 |
Incorrect |
1 ms |
376 KB |
Output isn't correct |
38 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
39 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
40 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |