#include "scales.h"
#include <bits/stdc++.h>
#define fst first
#define snd second
#define pb push_back
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(),x.end()
#define forn(i,a,b) for(int i = a; i < b; i++)
#define mset(a,v) memset(a,v,sizeof(a))
#define FIN ios::sync_with_stdio(0); cout.tie(0); cin.tie(0);
using namespace std;
typedef long long ll;
void init(int T) {
/* ... */
}
void orderCoins() {
/* ... */
vector<ll> p1 = {1,2,3};
vector<ll> s1(3);
s1[2]=getHeaviest(1,2,3);
s1[1]=getMedian(1,2,3);
p1.erase(find(ALL(p1),s1[2]));
p1.erase(find(ALL(p1),s1[1]));
s1[0]=p1[0];
vector<ll> p2 = {4,5,6};
vector<ll> s2(3);
s2[2]=getHeaviest(4,5,6);
s2[1]=getMedian(4,5,6);
p2.erase(find(ALL(p2),s2[2]));
p2.erase(find(ALL(p2),s2[1]));
s2[0]=p2[0];
vector<ll> left(6,-5);
vector<ll> right(6,-5);
forn(i,0,3) left[s1[i]-1]=s1[i-1]-1, right[s1[i]-1]=(i<2?s1[i+1]-1:-1);
ll men = getLightest(s1[0],s2[0],s2[1]);
if(men==s2[0]){
swap(s1,s2);
}
right[s2[0]-1] = right[s1[0]-1];
right[s1[0]-1]=s2[0]-1;
left[s2[0]-1]= s1[0]-1;
left[right[s2[0]-1]]=s2[0]-1;
//cout<<"pasa\n";
forn(i,1,3){
//cout<<s1[0]<<" "<<s1[1]<<" "<<s1[2]<<" "<<s2[i]<<'\n';
ll p = getNextLightest(s1[0],s1[1],s1[2],s2[i]);
// si es mayor a todos devuelve s1[0] -> se puede detectar si s1[0] es menor que s2[0]
// sino devuelve el menor que sea mayor
if(p==s1[0]){
forn(j,0,6){
if(right[j]==-1){
right[j]=s2[i]-1;
left[s2[i]-1]=j;
right[s2[i]-1]=-1;
}
}
}else{
right[s2[i]-1]=p-1;
left[s2[i]-1]=left[p-1];
right[left[p-1]]=s2[i]-1;
left[p-1]=s2[i]-1;
}
}
//forn(i,0,6) cout<<left[i]<<" "<<right[i]<<'\n';
vector<ll> res;
ll ind = men-1;
while(ind!=-1){
//cout<<ind+1<<'\n';
res.pb(ind+1);
ind=right[ind];
}
int W[] = {res[0], res[1], res[2], res[3], res[4], res[5]};
answer(W);
}
Compilation message (stderr)
scales.cpp: In function 'void orderCoins()':
scales.cpp:98:62: warning: narrowing conversion of 'res.std::vector<long long int>::operator[](0)' from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' [-Wnarrowing]
98 | int W[] = {res[0], res[1], res[2], res[3], res[4], res[5]};
| ^
scales.cpp:98:62: warning: narrowing conversion of 'res.std::vector<long long int>::operator[](1)' from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' [-Wnarrowing]
scales.cpp:98:62: warning: narrowing conversion of 'res.std::vector<long long int>::operator[](2)' from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' [-Wnarrowing]
scales.cpp:98:62: warning: narrowing conversion of 'res.std::vector<long long int>::operator[](3)' from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' [-Wnarrowing]
scales.cpp:98:62: warning: narrowing conversion of 'res.std::vector<long long int>::operator[](4)' from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' [-Wnarrowing]
scales.cpp:98:62: warning: narrowing conversion of 'res.std::vector<long long int>::operator[](5)' from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' [-Wnarrowing]
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |