# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
41792 |
2018-02-21T08:39:35 Z |
funcsr |
Scales (IOI15_scales) |
C++14 |
|
3 ms |
584 KB |
#include "scales.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(x) x.begin(), x.end()
#define uniq(x) x.erase(unique(all(x)), x.end())
#define index(x, y) (int)(lower_bound(all(x), y) - x.begin())
#define pb push_back
#define _1 first
#define _2 second
typedef pair<int, int> P;
void init(int T) {}
void solve3(vector<int> rest, vector<int> &ret) {
//cout<<"solve3("<<rest[0]<<","<<rest[1]<<","<<rest[2]<<")\n";
assert(rest.size() == 3);
int a = getHeaviest(rest[0], rest[1], rest[2]);
int b = getMedian(rest[0], rest[1], rest[2]);
ret.pb(a);
ret.pb(b);
for (int x : rest) if (x != a && x != b) ret.pb(x);
}
void solve4(vector<int> rest, vector<int> &ret) {
assert(rest.size() == 4);
// +2
int a = getHeaviest(rest[0], rest[1], rest[2]);
int tekitou = -1;
for (int x : rest) if (x != rest[3] && x != a) tekitou = x;
int mx = -1;
if (a == getHeaviest(a, rest[3], tekitou)) mx = a;
else mx = rest[3];
ret.pb(mx);
vector<int> new_rest;
for (int x : rest) if (x != mx) new_rest.pb(x);
solve3(new_rest, ret);
}
void orderCoins() {
int max_123 = getHeaviest(1, 2, 3);
int max_456 = getHeaviest(4, 5, 6);
int tekitou = 1;
while (tekitou==max_123 || tekitou==max_456) tekitou++;
vector<int> ret;
if (getHeaviest(max_123, max_456, tekitou) == max_123) {
vector<int> x;
for (int i=1; i<=3; i++) if (i != max_123) x.pb(i);
ret.pb(max_123);
int sec = getHeaviest(x[0], x[1], max_456);
ret.pb(sec);
vector<int> rest;
for (int i=1; i<=6; i++) if (i != max_123 && i != sec) rest.pb(i);
solve4(rest, ret);
}
else {
vector<int> x;
for (int i=4; i<=6; i++) if (i != max_456) x.pb(i);
ret.pb(max_456);
int sec = getHeaviest(x[0], x[1], max_123);
ret.pb(sec);
vector<int> rest;
for (int i=1; i<=6; i++) if (i != max_456 && i != sec) rest.pb(i);
solve4(rest, ret);
}
assert(ret.size() == 6);
reverse(all(ret));
int W[] = {ret[0], ret[1], ret[2], ret[3], ret[4], ret[5]};
//cout<<"["; rep(i, 6)cout<<W[i]<<",";cout<<"]\n";
answer(W);
}
Compilation message
scales.cpp:18:15: warning: unused parameter 'T' [-Wunused-parameter]
void init(int T) {}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
248 KB |
Output is partially correct |
2 |
Partially correct |
2 ms |
392 KB |
Output is partially correct |
3 |
Partially correct |
3 ms |
392 KB |
Output is partially correct |
4 |
Partially correct |
2 ms |
416 KB |
Output is partially correct |
5 |
Partially correct |
2 ms |
488 KB |
Output is partially correct |
6 |
Partially correct |
2 ms |
488 KB |
Output is partially correct |
7 |
Partially correct |
2 ms |
488 KB |
Output is partially correct |
8 |
Partially correct |
1 ms |
560 KB |
Output is partially correct |
9 |
Partially correct |
2 ms |
560 KB |
Output is partially correct |
10 |
Partially correct |
2 ms |
560 KB |
Output is partially correct |
11 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
12 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
13 |
Partially correct |
1 ms |
584 KB |
Output is partially correct |
14 |
Partially correct |
1 ms |
584 KB |
Output is partially correct |
15 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
16 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
17 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
18 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
19 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
20 |
Partially correct |
1 ms |
584 KB |
Output is partially correct |
21 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
22 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
23 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
24 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
25 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
26 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
27 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
28 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
29 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
30 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
31 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
32 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
33 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
34 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
35 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
36 |
Partially correct |
1 ms |
584 KB |
Output is partially correct |
37 |
Partially correct |
1 ms |
584 KB |
Output is partially correct |
38 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
39 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |
40 |
Partially correct |
2 ms |
584 KB |
Output is partially correct |