Submission #552002

#TimeUsernameProblemLanguageResultExecution timeMemory
552002Theo830Scales (IOI15_scales)C++17
71.43 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training #include "scales.h" void init(int T) { } void orderCoins() { int W[] = {1, 2, 3, 4, 5, 6}; vector<int>ex[2]; ex[0].pb(getHeaviest(1,2,3)); set<ll>e; f(i,0,3){ e.insert(i+1); } e.erase(ex[0].back()); for(auto x:e){ ex[0].insert(ex[0].begin(),x); } ex[1].pb(getHeaviest(4,5,6)); e.clear(); f(i,3,6){ e.insert(i+1); } e.erase(ex[1].back()); for(auto x:e){ ex[1].insert(ex[1].begin(),x); } W[5] = getHeaviest(ex[1].back(),ex[0].back(),ex[1][1]); if(W[5] != ex[1].back()){ swap(ex[0],ex[1]); } if(ex[0][1] != getMedian(ex[0][0],ex[0][1],ex[0][2])){ swap(ex[0][0],ex[0][1]); } ll p = getNextLightest(ex[1][0],ex[1][1],ex[1][2],ex[0][1]); if(p == ex[1][2]){ W[4] = ex[0][2]; W[3] = ex[0][1]; W[0] = getLightest(ex[0][0],ex[1][1],ex[1][0]); W[1] = getMedian(ex[0][0],ex[1][1],ex[1][0]); W[2] = ex[0][0] + ex[1][1] + ex[1][0] - W[0] - W[1]; } else{ ll o = ex[1][0] + ex[1][1] - p; ll p2 = getNextLightest(ex[0][0],ex[0][1],W[5],o); if(p2 == ex[0][0]){ W[0] = o; W[1] = ex[0][0]; W[2] = ex[0][1]; W[3] = getLightest(ex[0][2],p,W[5]); W[4] = ex[0][2] + p - W[3]; } else if(p2 == ex[0][1]){ W[0] = ex[0][0]; W[1] = o; W[2] = ex[0][1]; W[3] = getLightest(ex[0][2],p,W[5]); W[4] = ex[0][2] + p - W[3]; } else{ W[0] = ex[0][0]; W[1] = ex[0][1]; W[3] = getMedian(ex[0][2],o,p); if(W[3] == p){ W[4] = o; W[2] = ex[0][2]; } else if(W[3] == o){ W[2] = p; W[4] = ex[0][2]; } else{ W[2] = p; W[4] = o; } } } answer(W); }

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:26:15: warning: unused parameter 'T' [-Wunused-parameter]
   26 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:39:36: warning: conversion from 'long long int' to 'std::vector<int>::value_type' {aka 'int'} may change value [-Wconversion]
   39 |         ex[0].insert(ex[0].begin(),x);
      |                                    ^
scales.cpp:48:36: warning: conversion from 'long long int' to 'std::vector<int>::value_type' {aka 'int'} may change value [-Wconversion]
   48 |         ex[1].insert(ex[1].begin(),x);
      |                                    ^
scales.cpp:67:56: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   67 |         ll p2 = getNextLightest(ex[0][0],ex[0][1],W[5],o);
      |                                                        ^
scales.cpp:69:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   69 |             W[0] = o;
      |                    ^
scales.cpp:72:41: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   72 |             W[3] = getLightest(ex[0][2],p,W[5]);
      |                                         ^
scales.cpp:73:33: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   73 |             W[4] = ex[0][2] + p - W[3];
scales.cpp:77:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   77 |             W[1] = o;
      |                    ^
scales.cpp:79:41: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   79 |             W[3] = getLightest(ex[0][2],p,W[5]);
      |                                         ^
scales.cpp:80:33: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   80 |             W[4] = ex[0][2] + p - W[3];
scales.cpp:85:39: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   85 |             W[3] = getMedian(ex[0][2],o,p);
      |                                       ^
scales.cpp:85:41: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   85 |             W[3] = getMedian(ex[0][2],o,p);
      |                                         ^
scales.cpp:87:24: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   87 |                 W[4] = o;
      |                        ^
scales.cpp:91:24: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   91 |                 W[2] = p;
      |                        ^
scales.cpp:95:24: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   95 |                 W[2] = p;
      |                        ^
scales.cpp:96:24: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   96 |                 W[4] = o;
      |                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...