# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
937721 | 2024-03-04T11:56:17 Z | danikoynov | Scales (IOI15_scales) | C++14 | 1 ms | 600 KB |
#include "scales.h" #include<bits/stdc++.h> using namespace std; void init(int T) { /* ... */ } void sort_range(int l, int r, int w[]) { int a = w[l], b = w[l + 1], c = w[r]; ///cout << "sort range " << a << " " << b << " " << c << endl; int mid = getMedian(a, b, c); int low = getLightest(a, b, c); int high = a; if (low == a || mid == a) { high = b; if (mid == b || low == b) high = c; } w[l] = low; w[l + 1] = mid; w[r] = high; } void merge_sort(int w[]) { vector < int > res; int lf = 0, rf = 3; int ch = getMedian(w[0], w[1], w[3]); int lightest; if (ch == w[1]) { lightest = w[0]; res.push_back(w[0]); res.push_back(w[1]); lf += 2; } else if (ch == w[3]) { lightest = w[0]; res.push_back(w[0]); res.push_back(w[3]); lf ++; rf ++; } else { lightest = w[3]; res.push_back(w[3]); rf ++; } while(lf <= 2 && rf <= 5 && (3 - lf + 6 - rf > 3)) { if (getHeaviest(w[lf], w[rf], lightest) == w[lf]) res.push_back(w[rf ++]); else res.push_back(w[lf ++]); } if (rf > 5) while(lf <= 2) res.push_back(w[lf ++]); if (lf > 5) while(rf <= 5) res.push_back(w[rf ++]); if (lf == 1) { int mid = getMedian(w[lf], w[lf + 1], w[rf]); if (mid == w[lf]) { res.push_back(w[rf]); res.push_back(w[lf]); res.push_back(w[lf + 1]); } else if (mid == w[lf + 1]) { res.push_back(w[lf]); res.push_back(w[lf + 1]); res.push_back(w[rf]); } else if (mid == w[rf]) { res.push_back(w[lf]); res.push_back(w[rf]); res.push_back(w[lf + 1]); } } else if (rf == 4) { int mid = getMedian(w[lf], w[rf], w[rf + 1]); if (mid == w[rf]) { res.push_back(w[lf]); res.push_back(w[rf]); res.push_back(w[rf + 1]); } else if (mid == w[rf + 1]) { res.push_back(w[rf]); res.push_back(w[rf + 1]); res.push_back(w[lf]); } else if (mid == w[lf]) { res.push_back(w[rf]); res.push_back(w[lf]); res.push_back(w[rf + 1]); } } for (int i = 0; i < res.size(); i ++) w[i] = res[i]; } void orderCoins() { /* ... */ int W[] = {1, 2, 3, 4, 5, 6}; sort_range(0, 2, W); sort_range(3, 5, W); /**for (int i = 0; i < 6; i ++) cout << W[i] << " "; cout << endl; exit(0);*/ merge_sort(W); answer(W); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Partially correct | 0 ms | 348 KB | Output is partially correct |
2 | Partially correct | 0 ms | 348 KB | Output is partially correct |
3 | Partially correct | 0 ms | 432 KB | Output is partially correct |
4 | Partially correct | 0 ms | 348 KB | Output is partially correct |
5 | Partially correct | 0 ms | 348 KB | Output is partially correct |
6 | Partially correct | 0 ms | 600 KB | Output is partially correct |
7 | Partially correct | 0 ms | 348 KB | Output is partially correct |
8 | Partially correct | 0 ms | 348 KB | Output is partially correct |
9 | Partially correct | 0 ms | 348 KB | Output is partially correct |
10 | Partially correct | 0 ms | 348 KB | Output is partially correct |
11 | Partially correct | 0 ms | 348 KB | Output is partially correct |
12 | Partially correct | 0 ms | 348 KB | Output is partially correct |
13 | Partially correct | 0 ms | 348 KB | Output is partially correct |
14 | Partially correct | 0 ms | 348 KB | Output is partially correct |
15 | Partially correct | 0 ms | 348 KB | Output is partially correct |
16 | Partially correct | 0 ms | 348 KB | Output is partially correct |
17 | Partially correct | 0 ms | 348 KB | Output is partially correct |
18 | Partially correct | 0 ms | 344 KB | Output is partially correct |
19 | Partially correct | 0 ms | 348 KB | Output is partially correct |
20 | Partially correct | 0 ms | 348 KB | Output is partially correct |
21 | Partially correct | 0 ms | 348 KB | Output is partially correct |
22 | Partially correct | 0 ms | 344 KB | Output is partially correct |
23 | Partially correct | 0 ms | 344 KB | Output is partially correct |
24 | Partially correct | 1 ms | 600 KB | Output is partially correct |
25 | Partially correct | 0 ms | 348 KB | Output is partially correct |
26 | Partially correct | 0 ms | 348 KB | Output is partially correct |
27 | Partially correct | 0 ms | 348 KB | Output is partially correct |
28 | Partially correct | 0 ms | 348 KB | Output is partially correct |
29 | Partially correct | 0 ms | 348 KB | Output is partially correct |
30 | Partially correct | 0 ms | 348 KB | Output is partially correct |
31 | Partially correct | 0 ms | 344 KB | Output is partially correct |
32 | Partially correct | 0 ms | 344 KB | Output is partially correct |
33 | Partially correct | 0 ms | 348 KB | Output is partially correct |
34 | Partially correct | 0 ms | 348 KB | Output is partially correct |
35 | Partially correct | 0 ms | 348 KB | Output is partially correct |
36 | Partially correct | 0 ms | 348 KB | Output is partially correct |
37 | Partially correct | 0 ms | 348 KB | Output is partially correct |
38 | Partially correct | 0 ms | 348 KB | Output is partially correct |
39 | Partially correct | 0 ms | 348 KB | Output is partially correct |
40 | Partially correct | 1 ms | 348 KB | Output is partially correct |