# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
792141 | NothingXD | 저울 (IOI15_scales) | C++17 | 391 ms | 572 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef complex<ld> point;
void debug_out(){cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
cerr << H << ' ';
debug_out(T...);
}
#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)
vector<vector<int>> perm;
vector<vector<int>> query;
void init(int T) {
for (int d = 0; d < 6; d++){
for (int i = 0; i < 6; i++){
for (int j = i+1; j < 6; j++){
for (int k = j+1; k < 6; k++){
if (i == d || j == d || k == d) continue;
query.push_back({i, j, k, d});
}
}
}
}
for (auto x: {-2, -3, -1}){
for (int i = 0; i < 6; i++){
for (int j = i+1; j < 6; j++){
for (int k = j+1; k < 6; k++){
query.push_back({i, j, k, x});
}
}
}
}
}
int get(vector<int> a, int x, int y, int z, int idx){
if (perm.size() == 6) debug(x, y, z, idx);
vector<int> tmp = {a[x], a[y], a[z]};
sort(all(tmp));
if (tmp[idx] == a[x]) return 0;
if (tmp[idx] == a[y]) return 1;
if (tmp[idx] == a[z]) return 2;
}
int getnext(vector<int> a, int x, int y, int z, int d){
vector<int> tmp = {a[x], a[y], a[z]};
sort(all(tmp));
int idx = 0;
for (int i = 0; i < 3; i++){
if (tmp[i] > a[d]){
idx = i;
break;
}
}
if (tmp[idx] == a[x]) return 0;
if (tmp[idx] == a[y]) return 1;
if (tmp[idx] == a[z]) return 2;
}
void solve(){
//debug(perm.size());
if (perm.size() == 6){
for (auto x: perm){
for (auto y: x) cerr << y << ' ';
cerr << endl;
}
}
if (perm.size() == 1) return;
int mx = perm.size() + 1;
vector<vector<int>> ans[3];
vector<int> q;
for (auto x: query){
vector<vector<int>> res[3];
for (auto y: perm){
if (x[3] >= 0){
int tmp = getnext(y, x[0], x[1], x[2], x[3]);
res[tmp].push_back(y);
}
else{
int tmp = get(y, x[0], x[1], x[2], -x[3] - 1);
res[tmp].push_back(y);
}
}
if (perm.size() == 6 && x[3] < 0){
// debug(x[0], x[1], x[2], x[3], res[0].size(), res[1].size(), res[2].size());
}
int tmp = max({res[0].size(), res[1].size(), res[2].size()});
if (tmp < mx){
mx = tmp;
for (int i = 0; i < 3; i++){
ans[i] = res[i];
}
q = x;
}
}
assert(mx != perm.size());
if (q[3] >= 0){
int tmp = getNextLightest(q[0]+1, q[1]+1, q[2]+1, q[3]+1) - 1;
for (int i = 0; i < 3; i++){
if (tmp == q[i]) perm = ans[i];
}
}
else{
int tmp;
switch(q[3]){
case -1:
tmp = getLightest(q[0]+1, q[1]+1, q[2]+1)-1;
break;
case -2:
tmp = getMedian(q[0]+1, q[1]+1, q[2]+1)-1;
break;
case -3:
tmp = getHeaviest(q[0]+1, q[1]+1, q[2]+1)-1;
break;
}
for (int i = 0; i < 3; i++){
if (tmp == q[i]) perm = ans[i];
}
}
solve();
}
int cnt = 0;
void orderCoins() {
cnt++;
debug(cnt);
vector<int> tmp = {0, 1, 2, 3, 4, 5};
perm.clear();
do{
perm.push_back(tmp);
} while(next_permutation(all(tmp)));
//debug(perm.size());
solve();
int ans[6];
for (int i = 0; i < 6; i++) ans[perm[0][i]] = i+1;
answer(ans);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |