Submission #604329

#TimeUsernameProblemLanguageResultExecution timeMemory
6043298e7Scales (IOI15_scales)C++17
56.08 / 100
1 ms212 KiB
//Challenge: Accepted #include <bits/stdc++.h> using namespace std; #ifdef zisk void debug(){cout << endl;} template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);} template<class T> void pary(T l, T r){ while (l != r) cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif #define ll long long #define maxn 100005 #define pii pair<int, int> #define ff first #define ss second #include "scales.h" void init(int T) { /* ... */ } void orderCoins() { int n = 3; int a[3] = {1, 2, 3}, b[3] = {4, 5, 6}; int ret[6]; int ind = find(a, a + n, getLightest(a[0], a[1], a[2])) - a; swap(a[ind], a[0]); ind = find(b, b + n, getLightest(b[0], b[1], b[2])) - b; swap(b[ind], b[0]); //a[0] < a[1], a[2], b[0] < b[1], b[2]; int tmp = getHeaviest(a[0], b[1], b[2]); if (tmp == a[0]) { ind = find(b, b + n, getHeaviest(b[0], b[1], b[2])) - b; swap(b[ind], b[2]); ind = find(a, a + n, getHeaviest(a[0], a[1], a[2])) - a; swap(a[ind], a[2]); int r[6] = {b[0], b[1], b[2], a[0], a[1], a[2]}; answer(r); return; } else { if (tmp == b[1]) swap(b[1], b[2]); } tmp = getHeaviest(b[0], a[1], a[2]); if (tmp == b[0]) { ind = find(b, b + n, getHeaviest(b[0], b[1], b[2])) - b; swap(b[ind], b[2]); ind = find(a, a + n, getHeaviest(a[0], a[1], a[2])) - a; swap(a[ind], a[2]); int r[6] = {a[0], a[1], a[2], b[0], b[1], b[2]}; answer(r); return; } else { if (tmp == a[1]) swap(a[1], a[2]); } int pos[3] = {0, 0, 0}; bool det = 0; for (int i = 0;i < 3;i++) { ind = getNextLightest(a[0], a[1], a[2], b[i]); if (ind == a[1]) { pos[i] = 1; } else if (ind == a[2]) { pos[i] = 2; } else { if (i == 0) pos[i] = 0; else if (i == 2) pos[i] = 3; else { det = 1; } } } if (det) { if (pos[0] > 0) pos[1] = 3; else if (pos[2] < 3) pos[1] = 0; else { if (getHeaviest(a[0], a[2], b[1]) == b[1]) pos[1] = 3; else pos[1] = 0; } } ind = 0; int cur = 0; for (int i = 0;i < 3;i++) { while (ind < 3 && pos[ind] <= i) ret[cur++] = b[ind++]; ret[cur++] = a[i]; } while (ind < 3) ret[cur++] = b[ind++]; answer(ret); }

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:22:15: warning: unused parameter 'T' [-Wunused-parameter]
   22 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:31:58: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   31 |  int ind = find(a, a + n, getLightest(a[0], a[1], a[2])) - a;
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
scales.cpp:34:54: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   34 |  ind = find(b, b + n, getLightest(b[0], b[1], b[2])) - b;
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
scales.cpp:40:55: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   40 |   ind = find(b, b + n, getHeaviest(b[0], b[1], b[2])) - b;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
scales.cpp:42:55: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   42 |   ind = find(a, a + n, getHeaviest(a[0], a[1], a[2])) - a;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
scales.cpp:53:55: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   53 |   ind = find(b, b + n, getHeaviest(b[0], b[1], b[2])) - b;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
scales.cpp:55:55: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   55 |   ind = find(a, a + n, getHeaviest(a[0], a[1], a[2])) - a;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...