Submission #668620

#TimeUsernameProblemLanguageResultExecution timeMemory
668620alvingogo저울 (IOI15_scales)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "scales.h"
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;

void init(int T){

}
int fg(int a,int b,int c){
    return getHeaviest(a,b,c);
}
int fm(int a,int b,int c){
    return getMedian(a,b,c);
}
int fl(int a,int b,int c){
    return getLightest(a,b,c);
}
int nx(int a,int b,int c,int d){
    return getNextLightest(a,b,c,d);
}
vector<int> st(int a,int b,int c,int d){
    vector<int> g(4);
    g[0]=a;
    g[1]=b;
    g[2]=c;
    g[3]=d;
    return g;
}
vector<int> sort4(int d,int e,int f,int a){
    int x=fm(d,e,f);
    if(x!=d){
        if(x==e){
            swap(d,e);
        }
        else{
            swap(d,f);
        }
    }
    int y=fl(a,d,e);
    if(y==e){
        int z=nx(e,d,f,a);
        if(z==e){
            return st(e,d,f,a);
        }
        else if(z==f){
            return st(e,d,a,f);
        }
        else{
            return st(e,a,d,f);
        }
    }
    else if(y==d){
        int z=fg(d,e,a);
        if(z==e){
            return st(f,d,a,e);
        }
        else{
            return st(f,d,e,a);
        }
    }
    else{
        int z=fm(a,f,d);
        if(z==a){
            return st(f,a,d,e);
        }
        else if(z==f){
            return st(a,f,d,e);
        }
        else{
            return st(a,e,d,f);
        }
    }
}
void orderCoins(){
    int a=fm(1,2,3);
    vector<int> x;
    for(int i=1;i<=3;i++){
        if(i!=a && i!=b){
            x.push_back(i);
        }
    }
    auto h=sort4(a,4,5,6);
    int b=fl(1,2,3);
    int c=6-a-b;
    int ans[6]={0};
    for(int i=0;i<4;i++){
        if(h[i]==a){
            if(i==0){
                ans[0]=b;
                ans[1]=a;
                int u=nx(h[1],h[2],h[3],c);
                if(u==h[2]){
                    ans[2]=h[1];
                    ans[3]=c;
                    ans[4]=h[2];
                    ans[5]=h[3];
                }
                else if(u==h[3]){
                    ans[2]=h[1];
                    ans[3]=h[2];
                    ans[4]=c;
                    ans[5]=h[3];
                }
                else{
                    int x=fg(h[2],h[3],c);
                    if(x==c){
                        ans[2]=h[1];
                        ans[3]=h[2];
                        ans[4]=h[3];
                        ans[5]=c;
                    }
                    else{
                        ans[2]=c;
                        ans[3]=h[1];
                        ans[4]=h[2];
                        ans[5]=h[3];
                    }
                }
            }
            if(i==3){
                ans[5]=c;
                ans[4]=a;
                int u=nx(h[0],h[1],h[2],b);
                if(u==h[2]){
                    ans[3]=h[2];
                    ans[2]=b;
                    ans[1]=h[1];
                    ans[0]=h[0];
                }
                else if(u==h[1]){
                    ans[3]=h[2];
                    ans[2]=h[1];
                    ans[1]=b;
                    ans[0]=h[0];
                }
                else{
                    int x=fl(h[0],h[1],b);
                    if(x==a){
                        ans[3]=h[2];
                        ans[2]=h[1];
                        ans[1]=h[0];
                        ans[0]=c;
                    }
                    else{
                        ans[3]=c;
                        ans[2]=h[2];
                        ans[1]=h[1];
                        ans[0]=h[0];
                    }
                }
            }
            if(i==1){
                ans[2]=a;
                int x=fl(b,h[0],h[1]);
                if(x==b){
                    ans[0]=b;
                    ans[1]=h[0];
                }
                else{
                    ans[0]=h[0];
                    ans[1]=b;
                }
                int y=nx(h[1],h[2],h[3],c);
                if(y==h[3]){
                    ans[3]=h[2];
                    ans[4]=c;
                    ans[5]=h[3];
                }
                else if(y==h[2]){
                    ans[3]=c;
                    ans[4]=h[2];
                    ans[5]=h[3];
                }
                else{
                    ans[3]=h[2];
                    ans[4]=h[3];
                    ans[5]=c;
                }
            }  
            if(i==2){
                ans[3]=a;
                int x=fg(c,h[2],h[3]);
                if(x==c){
                    ans[5]=c;
                    ans[4]=h[3];
                }
                else{
                    ans[5]=h[3];
                    ans[4]=c;
                }
                int y=nx(h[0],h[1],h[2],b);
                if(y==h[2]){
                    ans[2]=b;
                    ans[1]=h[1];
                    ans[0]=h[0];
                }
                else if(y==h[1]){
                    ans[2]=h[1];
                    ans[1]=b;
                    ans[0]=h[0];
                }
                else{
                    ans[2]=h[1];
                    ans[1]=h[0];
                    ans[0]=b;
                }
            } 
        }
    }
    answer(ans);
}

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:10:15: warning: unused parameter 'T' [-Wunused-parameter]
   10 | void init(int T){
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:82:23: error: 'b' was not declared in this scope
   82 |         if(i!=a && i!=b){
      |                       ^
scales.cpp:109:25: warning: declaration of 'x' shadows a previous local [-Wshadow]
  109 |                     int x=fg(h[2],h[3],c);
      |                         ^
scales.cpp:80:17: note: shadowed declaration is here
   80 |     vector<int> x;
      |                 ^
scales.cpp:141:25: warning: declaration of 'x' shadows a previous local [-Wshadow]
  141 |                     int x=fl(h[0],h[1],b);
      |                         ^
scales.cpp:80:17: note: shadowed declaration is here
   80 |     vector<int> x;
      |                 ^
scales.cpp:158:21: warning: declaration of 'x' shadows a previous local [-Wshadow]
  158 |                 int x=fl(b,h[0],h[1]);
      |                     ^
scales.cpp:80:17: note: shadowed declaration is here
   80 |     vector<int> x;
      |                 ^
scales.cpp:186:21: warning: declaration of 'x' shadows a previous local [-Wshadow]
  186 |                 int x=fg(c,h[2],h[3]);
      |                     ^
scales.cpp:80:17: note: shadowed declaration is here
   80 |     vector<int> x;
      |                 ^