Submission #551808

#TimeUsernameProblemLanguageResultExecution timeMemory
551808Theo830Scales (IOI15_scales)C++17
Compilation error
0 ms0 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(getLightest(1,2,3)); ex[0].pb(getMedian(1,2,3)); set<ll>e; f(i,0,3){ e.insert(i+1); } for(auto x:ex[0]){ e.erase(x); } ex[0].pb((*e.begin())); ex[1].pb(getLightest(4,5,6)); ex[1].pb(getMedian(4,5,6)); set<ll>e; f(i,3,6){ e.insert(i+1); } for(auto x:ex[1]){ e.erase(x); } ex[1].pb((*e.begin())); f(i,0,6){ if(ex[0].empty()){ W[i] = ex[1][0]; ex[1].erase(ex[1].begin()); } else if(ex[1].empty()){ W[i] = ex[0][0]; ex[0].erase(ex[0].begin()); } else{ if((ll)(ex[0].size() + ex[1].size()) == 2){ W[i] = getMedian(ex[0][0],ex[1][0],W[i-1]); } else{ ll v; if(ex[0].size() > 1){ v = ex[0][1]; } else{ v = ex[1][1]; } W[i] = getLightest(ex[0][0],ex[1][0],v); } if(W[i] == ex[0][0]){ ex[0].erase(ex[0].begin()); } else{ ex[1].erase(ex[1].begin()); } } } 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:41:15: warning: conversion from 'long long int' to 'std::vector<int>::value_type' {aka 'int'} may change value [-Wconversion]
   41 |     ex[0].pb((*e.begin()));
      |              ~^~~~~~~~~~~
scales.cpp:44:12: error: redeclaration of 'std::set<long long int> e'
   44 |     set<ll>e;
      |            ^
scales.cpp:34:12: note: 'std::set<long long int> e' previously declared here
   34 |     set<ll>e;
      |            ^
scales.cpp:51:15: warning: conversion from 'long long int' to 'std::vector<int>::value_type' {aka 'int'} may change value [-Wconversion]
   51 |     ex[1].pb((*e.begin()));
      |              ~^~~~~~~~~~~
scales.cpp:73:54: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   73 |                 W[i] = getLightest(ex[0][0],ex[1][0],v);
      |                                                      ^