#include <bits/stdc++.h>
#include "scales.h"
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define forn(i, l, r) for(int i = l; i <= r; ++i)
#define ford(i, r, l) for(int i = r; i >= l; --i)
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define task "MEETING"
#define endl "\n"
#define C(x, y) make_pair(x, y)
template<typename T> bool maximize(T &res, const T &val) { if (res <= val){ res = val; return true; }; return false; }
template<typename T> bool minimize(T &res, const T &val) { if (res >= val){ res = val; return true; }; return false; }
const int N = 8 + 7;
const int MOD = 1e9 + 7 ;
const int INF = 1e13 + 9999;
const int block_size = 230;
const int offset = N;
const int LIM = 721;
int p[N], pos[LIM][7], b[LIM], nx[LIM], n;
int find_nx(int x)
{
if(!b[nx[x]]) return nx[x];
return nx[x] = find_nx(nx[x]);
}
void init(int T)
{
int idx = 0;
nx[0] = 1;
rep(i, 6) p[i] = i;
do
{
++idx;
rep(i, 6) pos[idx][p[i]] = 1;
nx[idx] = idx + 1;
} while(next_permutation(p + 1, p + 1 + 6));
}
int w[6];
struct condition {
int type;
int a, b, c, d;
int res;
condition(){}
condition(int type_, int a_, int b_, int c_) : type(type_), a(a_), b(b_), c(c_){}
condition(int type_, int a_, int b_, int c_, int d_) : type(type_), a(a_), b(b_), c(c_), d(d_){}
};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<condition> q;
void update()
{
auto e = q.back();
int type = e.type;
int a = e.a, b = e.b, c = e.c, d = e.d;
if(type == 0)
e.res = getLightest(a, b, c);
else if(type == 1)
e.res = getMedian(a, b, c);
else if(type == 0)
e.res = getHeaviest(a, b, c);
else e.res = getNextLightest(a, b, c, d);
}
int tmp[3];
bool check(int idx)
{
for(auto e : q)
{
int type = e.type;
int a = e.a, b = e.b, c = e.c, res = e.res;
tmp[0] = a;
tmp[1] = b;
tmp[2] = c;
sort(tmp, tmp + 2, [&idx](int x, int y) {
return pos[idx][x] < pos[idx][y];
});
if(type != 3)
{
if(type == 0)
{
if(res == a) return 1;
return 0;
}
else if(type == 1)
{
if(res == b) return 1;
return 0;
}
else
{
if(res == c) return 1;
return 0;
}
}
else
{
int d = e.d;
if(pos[d] < pos[a])
{
if(res == a) return 0;
return 1;
}
if(pos[d] < pos[b])
{
if(res == b) return 0;
return 1;
}
if(res != c) return 1;
return 0;
}
}
}
int randint(int l, int r)
{
return rng() % (r - l + 1) + l;
}
void orderCoins()
{
answer(w);
int cnt = 720;
rep(i, 720) b[i] = 0;
while(cnt > 1)
{
int type = rng() % 4;
if(type != 3)
{
int a = randint(1, 4);
int b = randint(a + 1, 5);
int c = randint(b + 1, 6);
if(randint(0, 1)) swap(a, b);
if(randint(0, 1)) swap(a, c);
if(randint(0, 1)) swap(b, c);
q.push_back(condition(type, a, b, c));
}
else
{
int a = randint(1, 3);
int b = randint(a + 1, 4);
int c = randint(b + 1, 5);
int d = randint(c + 1, 6);
if(randint(0, 1)) swap(a, b);
if(randint(0, 1)) swap(a, c);
if(randint(0, 1)) swap(b, c);
if(randint(0, 1)) swap(b, d);
q.push_back(condition(type, a, b, c, d));
}
int idx = find_nx(0);
for(; idx <= n; idx = find_nx(idx))
{
if(check(idx)) --cnt, b[idx] = 0;
}
}
}
Compilation message
scales.cpp:26:22: warning: overflow in conversion from 'double' to 'int' changes value from '1.0000000009999e+13' to '2147483647' [-Woverflow]
26 | const int INF = 1e13 + 9999;
| ~~~~~^~~~~~
scales.cpp: In function 'void init(int)':
scales.cpp:39:15: warning: unused parameter 'T' [-Wunused-parameter]
39 | void init(int T)
| ~~~~^
scales.cpp: In function 'void update()':
scales.cpp:71:18: warning: declaration of 'b' shadows a global declaration [-Wshadow]
71 | int a = e.a, b = e.b, c = e.c, d = e.d;
| ^
scales.cpp:31:24: note: shadowed declaration is here
31 | int p[N], pos[LIM][7], b[LIM], nx[LIM], n;
| ^
scales.cpp: In function 'bool check(int)':
scales.cpp:89:22: warning: declaration of 'b' shadows a global declaration [-Wshadow]
89 | int a = e.a, b = e.b, c = e.c, res = e.res;
| ^
scales.cpp:31:24: note: shadowed declaration is here
31 | int p[N], pos[LIM][7], b[LIM], nx[LIM], n;
| ^
scales.cpp: In function 'int randint(int, int)':
scales.cpp:136:32: warning: conversion from 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::result_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
136 | return rng() % (r - l + 1) + l;
| ~~~~~~~~~~~~~~~~~~~~^~~
scales.cpp: In function 'void orderCoins()':
scales.cpp:150:17: warning: declaration of 'b' shadows a global declaration [-Wshadow]
150 | int b = randint(a + 1, 5);
| ^
scales.cpp:31:24: note: shadowed declaration is here
31 | int p[N], pos[LIM][7], b[LIM], nx[LIM], n;
| ^
scales.cpp:160:17: warning: declaration of 'b' shadows a global declaration [-Wshadow]
160 | int b = randint(a + 1, 4);
| ^
scales.cpp:31:24: note: shadowed declaration is here
31 | int p[N], pos[LIM][7], b[LIM], nx[LIM], n;
| ^
scales.cpp: In function 'bool check(int)':
scales.cpp:132:1: warning: control reaches end of non-void function [-Wreturn-type]
132 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
16 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
17 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
18 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
19 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
20 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
21 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
22 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
23 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
24 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
25 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
26 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
27 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
28 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
29 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
30 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
31 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
32 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
33 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
34 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
35 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
36 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
37 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
38 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
39 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
40 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |