# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
423960 | InternetPerson10 | Scales (IOI15_scales) | C++17 | 1 ms | 292 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;
void init(int T) {
/* ... */
}
int a[7][7];
vector<int> v[3];
void answer(int W[]);
void setVec(int a1, int a2, int a3, int a4, int i) {
v[i].push_back(a4);
for(int z = 0; z < 3; z++) {
int x = getNextLightest(a1, a2, a3, a4);
// cout << x << '\n';
if(x == a1) {
v[i].push_back(a1);
swap(a1, a4);
}
else if(x == a2) {
v[i].push_back(a2);
swap(a2, a4);
}
else {
v[i].push_back(a3);
swap(a3, a4);
}
}
int x = getLightest(v[i][0], v[i][1], v[i][2]);
int oo[4];
int g = -1;
if(x == v[i][1]) g = 1;
if(x == v[i][2]) g = 2;
x = getLightest(v[i][2], v[i][3], v[i][0]);
if(x == v[i][3]) g = 3;
if(x == v[i][0]) g = 0;
for(int z = 0; z < 4; z++) oo[z] = v[i][(z+g)%4];
for(int z = 0; z < 4; z++) v[i][z] = oo[z];
return;
}
void orderCoins() {
for(int i = 0; i < 7; i++) {
for(int j = 0; j < 7; j++) {
a[i][j] = 0;
}
}
for(int i = 0; i < 3; i++) vector<int>().swap(v[i]);
setVec(1, 2, 3, 4, 0);
setVec(1, 2, 5, 6, 1);
setVec(3, 4, 5, 6, 2);
vector<int> vec = {1, 2, 3, 4, 5, 6}, vec2 = {1, 2, 3, 4, 5, 6};
// for(int i = 0; i < 3; i++) {
// for(int j = 0; j < 4; j++) {
// cout << v[i][j] << ' ';
// }
// cout << '\n';
// }
bool sad = false;
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 4; j++) {
for(int k = j+1; k < 4; k++) {
a[v[i][j]][v[i][k]] = 1;
}
}
}
for(int i = 1; i < 7; i++) {
for(int j = 1; j < 7; j++) {
a[i][0] += a[i][j];
}
}
int W[] = {1, 2, 3, 4, 5, 6};
for(int i = 0; i < 6; i++) {
// cout << i << ' ' << a[i][0] << '\n';
W[5-a[i+1][0]] = i+1;
}
answer(W);
}
/*
// remove this in the end
static int _realC[6];
static int _ind[6];
static int _numQueries;
static int _numAnswerCalls;
void answer(int W[]) {
int i;
for (i = 0; i < 6; i++)
cout << W[i] << ' ';
cout << "\n" << _numQueries << '\n';
}
static void _checkQuery(int A, int B, int C, int D) {
if (D == -1) {
if (A < 1 || A > 6 || B < 1 || B > 6 || C < 1 || C > 6)
assert(0);
if (A == B || B == C || A == C)
assert(0);
}
else {
if (A < 1 || A > 6 || B < 1 || B > 6 || C < 1 || C > 6 || D < 1 || D > 6)
assert(0);
if (A == B || A == C || A == D || B == C || B == D || C == D)
assert(0);
}
}
int _getNumberOfTests() {
int T; cin >> T;
return T;
}
void _initNewTest() {
int i, ret;
for (i = 0; i < 6; i++) {
cin >> _realC[i];
_realC[i]--;
_ind[_realC[i]] = i;
}
_numQueries = 0;
_numAnswerCalls = 0;
}
int getMedian(int A, int B, int C) {
_numQueries++;
// _checkQuery(A, B, C, -1);
A--; B--; C--;
if (_ind[B] < _ind[A] && _ind[A] < _ind[C])
return A + 1;
if (_ind[C] < _ind[A] && _ind[A] < _ind[B])
return A + 1;
if (_ind[A] < _ind[B] && _ind[B] < _ind[C])
return B + 1;
if (_ind[C] < _ind[B] && _ind[B] < _ind[A])
return B + 1;
return C + 1;
}
int getHeaviest(int A, int B, int C) {
_numQueries++;
// _checkQuery(A, B, C, -1);
A--; B--; C--;
if (_ind[A] > _ind[B] && _ind[A] > _ind[C])
return A + 1;
if (_ind[B] > _ind[A] && _ind[B] > _ind[C])
return B + 1;
return C + 1;
}
int getLightest(int A, int B, int C) {
_numQueries++;
// _checkQuery(A, B, C, -1);
A--; B--; C--;
if (_ind[A] < _ind[B] && _ind[A] < _ind[C])
return A + 1;
if (_ind[B] < _ind[A] && _ind[B] < _ind[C])
return B + 1;
return C + 1;
}
int getNextLightest(int A, int B, int C, int D) {
int allLess = 1;
_numQueries++;
// _checkQuery(A, B, C, D);
A--; B--; C--; D--;
if (_ind[A] > _ind[D] || _ind[B] > _ind[D] || _ind[C] > _ind[D])
allLess = 0;
if (allLess == 1) {
if (_ind[A] < _ind[B] && _ind[A] < _ind[C])
return A + 1;
if (_ind[B] < _ind[A] && _ind[B] < _ind[C])
return B + 1;
return C + 1;
}
if (_ind[A] > _ind[D]) {
if ((_ind[A] < _ind[B] || _ind[B] < _ind[D]) && (_ind[A] < _ind[C] || _ind[C] < _ind[D]))
return A + 1;
}
if (_ind[B] > _ind[D]) {
if ((_ind[B] < _ind[A] || _ind[A] < _ind[D]) && (_ind[B] < _ind[C] || _ind[C] < _ind[D]))
return B + 1;
}
return C + 1;
}
int main() {
int T, i;
T = _getNumberOfTests();
init(T);
for (i = 1; i <= T; i++) {
_initNewTest();
orderCoins();
}
return 0;
}
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |