# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
761376 | Red_Inside | 저울 (IOI15_scales) | C++17 | 97 ms | 360 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "scales.h"
#include <bits/stdc++.h>
//#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
using namespace std;
const int maxn=188500+10,LOG=17,mod=1e9+7;
int block = 200, timer = 0;
const double eps = 1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define bt(i) (1 << (i))
//#define int ll
const int inf=2e9;
#define y1 yy
#define pii pair <int, int>
vector <int> perms[720];
void init(int T)
{
vector <int> vec;
forn(1, i, 6)
{
vec.pb(i);
}
int cnt = 0;
do
{
perms[cnt] = vec;
cnt++;
}while(next_permutation(all(vec)));
return;
}
int check(int num, int a, int b, int c, int res, int ty)
{
//types
//1 - min
//2 - mid
//3 - max
int pa, pb, pc;
FOR(0, i, perms[num].size())
{
if(perms[num][i] == a) pa = i;
if(perms[num][i] == b) pb = i;
if(perms[num][i] == c) pc = i;
}
int TrueRes;
int mn = min({pa, pb, pc});
int mx = max({pa, pb, pc});
if(ty == 1)
{
if(pa == mn) TrueRes = 1;
if(pb == mn) TrueRes = 2;
if(pc == mn) TrueRes = 3;
}
if(ty == 3)
{
if(pa == mx) TrueRes = 1;
if(pb == mx) TrueRes = 2;
if(pc == mx) TrueRes = 3;
}
if(ty == 2)
{
if(pa != mn && pa != mx) TrueRes = 1;
if(pb != mn && pb != mx) TrueRes = 2;
if(pc != mn && pc != mx) TrueRes = 3;
}
return (TrueRes == res);
}
int check4(int num, int a, int b, int c, int d, int res)
{
int pd;
int pa, pb, pc;
FOR(0, i, perms[num].size())
{
if(perms[num][i] == a) pa = i;
if(perms[num][i] == b) pb = i;
if(perms[num][i] == c) pc = i;
if(perms[num][i] == d) pd = i;
}
int TrueRes = -1;
if(max({pa, pb, pc}) < pd)
{
if(min({pa, pb, pc}) == pa) TrueRes = 1;
if(min({pa, pb, pc}) == pb) TrueRes = 2;
if(min({pa, pb, pc}) == pc) TrueRes = 3;
}
else
{
FOR(pd+1, i, perms[num].size())
{
if(i == pa)
{
TrueRes = 1;
break;
}
if(i == pb)
{
TrueRes = 2;
break;
}
if(i == pc)
{
TrueRes = 3;
break;
}
}
}
return (TrueRes == res);
}
void orderCoins()
{
vector <int> can;
forn(0, i, 719) can.pb(i);
while(can.size() > 1)
{
/*if(can.size() < 10)
{
cout << " POSSIBLE\n";
for(auto i : can)
{
forn(0, j, 5) cout << perms[i][j] << " ";
cout << "\n";
}
}*/
int tekans = inf;
vector <int> vec;
forn(1, ty, 3)
{
forn(1, i, 6)
{
forn(i + 1, j, 6)
{
forn(j + 1, k, 6)
{
int Res = -1;
forn(1, res, 3)
{
int cnt = 0;
for(auto per : can)
{
if(check(per, i, j, k, res, ty)) cnt++;
}
Res = max(Res, cnt);
}
if(Res < tekans)
{
tekans = Res;
vec = {ty, i, j, k};
}
}
}
}
}
forn(1, i, 6)
{
forn(i + 1, j, 6)
{
forn(j + 1, k, 6)
{
forn(1, it, 6)
{
if(it == i || it == j || it == k) continue;
int Res = 0;
forn(1, res, 3)
{
int cnt = 0;
for(auto per : can)
{
if(check4(per, i, j, k, it, res)) cnt++;
}
Res = max(Res, cnt);
}
if(Res < tekans)
{
tekans = Res;
vec = {4, i, j, k, it};
}
}
}
}
}
int res;
if(vec[0] == 4)
{
res = getNextLightest(vec[1], vec[2], vec[3], vec[4]);
if(res == vec[1]) res = 1;
if(res == vec[2]) res = 2;
if(res == vec[3]) res = 3;
vector <int> nw;
for(auto i : can)
{
if(check4(i, vec[1], vec[2], vec[3], vec[4], res)) nw.pb(i);
}
can = nw;
}
else
{
if(vec[0] == 1)
{
res = getLightest(vec[1], vec[2], vec[3]);
if(res == vec[1]) res = 1;
if(res == vec[2]) res = 2;
if(res == vec[3]) res = 3;
}
if(vec[0] == 2)
{
res = getMedian(vec[1], vec[2], vec[3]);
if(res == vec[1]) res = 1;
if(res == vec[2]) res = 2;
if(res == vec[3]) res = 3;
}
if(vec[0] == 3)
{
res = getHeaviest(vec[1], vec[2], vec[3]);
if(res == vec[1]) res = 1;
if(res == vec[2]) res = 2;
if(res == vec[3]) res = 3;
}
vector <int> nw;
for(auto i : can)
{
if(check(i, vec[1], vec[2], vec[3], res, vec[0])) nw.pb(i);
}
can = nw;
}
}
int W[6];
FOR(0, i, 6) W[i] = perms[can[0]][i];
answer(W);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |