Submission #1017620

#TimeUsernameProblemLanguageResultExecution timeMemory
1017620AmirAli_H1Scales (IOI15_scales)C++17
55.56 / 100
1 ms348 KiB
// In the name of Allah #include <bits/stdc++.h> #include "scales.h" using namespace std; typedef long long int ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef complex<ld> cld; #define all(x) (x).begin(),(x).end() #define len(x) ((ll) (x).size()) #define F first #define S second #define pb push_back #define sep ' ' #define endl '\n' #define Mp make_pair #define kill(x) cout << x << '\n', exit(0) #define set_dec(x) cout << fixed << setprecision(x); #define file_io(x,y) freopen(x, "r", stdin); freopen(y, "w", stdout); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int mark[7]; vector<int> res, vc, vcx; vector<int> adjr[7]; void init(int T) { return ; } void opr(int M) { if (M == 0) { int j = len(vc); int r = getLightest(vc[j - 1], vc[j - 2], vc[j - 3]); for (int x : {vc[j - 1], vc[j - 2], vc[j - 3]}) { if (x != r) adjr[x].pb(r); } vc.pop_back(); vc.pop_back(); vc.pop_back(); vc.pb(r); } else { int r = getLightest(vc[0], vc[1], vc[2]); for (int x : {vc[0], vc[1], vc[2]}) { if (x != r) adjr[x].pb(r); } vcx.clear(); vcx.pb(r); for (int i = 3; i < len(vc); i++) vcx.pb(vc[i]); swap(vc, vcx); } } int get_min() { vc.clear(); for (int i = 1; i <= 6; i++) { if (!mark[i]) { bool ok = 1; for (int j : adjr[i]) { if (!mark[j]) { ok = 0; break; } } if (ok) vc.pb(i); } } int M = 0; while (len(vc) >= 3) { opr(M); M ^= 1; } if (len(vc) == 2) { for (int i = 1; i <= 6; i++) { if (!mark[i]) { if (i != vc[0] && i != vc[1]) { vc.pb(i); break; } } } opr(M); M ^= 1; } return vc[0]; } void orderCoins() { fill(mark, mark + 7, 0); res.clear(); for (int i = 1; i <= 6; i++) adjr[i].clear(); for (int i = 0; i < 3; i++) { int x = get_min(); mark[x] = 1; res.pb(x); } while (len(res) < 5) { int x = res.back(); vc.clear(); for (int i = 1; i <= 6; i++) { if (!mark[i]) vc.pb(i); } for (int i = 1; i <= 6; i++) { if (len(vc) >= 3) break; if (mark[i] && i != x) vc.pb(i); } int r = getNextLightest(vc[0], vc[1], vc[2], x); mark[r] = 1; res.pb(r); } for (int i = 1; i <= 6; i++) { if (!mark[i]) { mark[i] = 1; res.pb(i); } } int W[6]; for (int i = 0; i < 6; i++) W[i] = res[i]; answer(W); }

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:30:15: warning: unused parameter 'T' [-Wunused-parameter]
   30 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void opr(int)':
scales.cpp:14:22: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   14 | #define  len(x)     ((ll) (x).size())
      |                     ~^~~~~~~~~~~~~~~~
scales.cpp:36:11: note: in expansion of macro 'len'
   36 |   int j = len(vc);
      |           ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...