제출 #676143

#제출 시각아이디문제언어결과실행 시간메모리
676143jamezzzScales (IOI15_scales)C++17
55.56 / 100
1 ms304 KiB
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;

void init(int T){}

inline int getOut(int a,int b,int c,int x,int y){
	if(x!=a&&y!=a)return a;
	if(x!=b&&y!=b)return b;
	return c;
}

inline void ans(int a,int b,int c,int d,int e,int f){
	int w[]={a,b,c,d,e,f};
	answer(w);
}

void orderCoins(){
	int a=getLightest(1,2,3);
	int b=getMedian(1,2,3);
	int c=getOut(1,2,3,a,b);
	int d=getLightest(4,5,6);
	int e=getMedian(4,5,6);
	int f=getOut(4,5,6,d,e);
	int x=getMedian(a,b,d);
	
	int epos,fpos;
	if(a==x){//D.A.B.C.
		int x=getMedian(a,e,f);
		int epos,fpos;
		if(x==a){
			epos=d;
			int y=getMedian(b,c,f);
			if(y==b)fpos=a;
			else if(y==c)fpos=c;
			else fpos=b;
		}
		else if(x==f)epos=fpos=d;
		else{
			int y=getMedian(b,c,e);
			int z=getMedian(b,c,f);
			
			if(y==b)epos=a;
			else if(y==c)epos=c;
			else epos=b;
			
			if(z==b)fpos=a;
			else if(z==c)fpos=c;
			else fpos=b;
		}
		
		vector<int> u={d,a,b,c},v={};
		for(int i:u){
			v.push_back(i);
			if(i==epos)v.push_back(e);
			if(i==fpos)v.push_back(f);
		}
		
		int w[]={0,0,0,0,0,0};
		for(int i=0;i<6;++i)w[i]=v[i];
		answer(w);
	}
	else if(b==x){//AB.D.E.F.
		int x=getMedian(b,c,d);
		if(x==c){
			ans(a,b,c,d,e,f);
			return;
		}
		
		int y=getMedian(c,e,f);
		if(y==e)ans(a,b,d,c,e,f);
		else if(y==f)ans(a,b,d,e,f,c);
		else ans(a,b,d,e,c,f);
		return;
	}
	else{//AD.B.C.
		int x=getMedian(b,c,e);
		int y=getMedian(b,c,f);
		
		int epos,fpos;
		if(x==b)epos=d;
		else if(x==c)epos=c;
		else epos=b;
		
		if(y==b)fpos=d;
		else if(y==c)fpos=c;
		else fpos=b;
		
		vector<int> u={a,d,b,c},v={};
		for(int i:u){
			v.push_back(i);
			if(i==epos)v.push_back(e);
			if(i==fpos)v.push_back(f);
		}
		
		int w[]={0,0,0,0,0,0};
		for(int i=0;i<6;++i)w[i]=v[i];
		answer(w);
	}
}

컴파일 시 표준 에러 (stderr) 메시지

scales.cpp: In function 'void init(int)':
scales.cpp:5:15: warning: unused parameter 'T' [-Wunused-parameter]
    5 | void init(int T){}
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:29:7: warning: declaration of 'x' shadows a previous local [-Wshadow]
   29 |   int x=getMedian(a,e,f);
      |       ^
scales.cpp:25:6: note: shadowed declaration is here
   25 |  int x=getMedian(a,b,d);
      |      ^
scales.cpp:30:7: warning: declaration of 'epos' shadows a previous local [-Wshadow]
   30 |   int epos,fpos;
      |       ^~~~
scales.cpp:27:6: note: shadowed declaration is here
   27 |  int epos,fpos;
      |      ^~~~
scales.cpp:30:12: warning: declaration of 'fpos' shadows a previous local [-Wshadow]
   30 |   int epos,fpos;
      |            ^~~~
scales.cpp:27:11: note: shadowed declaration is here
   27 |  int epos,fpos;
      |           ^~~~
scales.cpp:64:7: warning: declaration of 'x' shadows a previous local [-Wshadow]
   64 |   int x=getMedian(b,c,d);
      |       ^
scales.cpp:25:6: note: shadowed declaration is here
   25 |  int x=getMedian(a,b,d);
      |      ^
scales.cpp:77:7: warning: declaration of 'x' shadows a previous local [-Wshadow]
   77 |   int x=getMedian(b,c,e);
      |       ^
scales.cpp:25:6: note: shadowed declaration is here
   25 |  int x=getMedian(a,b,d);
      |      ^
scales.cpp:80:7: warning: declaration of 'epos' shadows a previous local [-Wshadow]
   80 |   int epos,fpos;
      |       ^~~~
scales.cpp:27:6: note: shadowed declaration is here
   27 |  int epos,fpos;
      |      ^~~~
scales.cpp:80:12: warning: declaration of 'fpos' shadows a previous local [-Wshadow]
   80 |   int epos,fpos;
      |            ^~~~
scales.cpp:27:11: note: shadowed declaration is here
   27 |  int epos,fpos;
      |           ^~~~
scales.cpp:27:6: warning: unused variable 'epos' [-Wunused-variable]
   27 |  int epos,fpos;
      |      ^~~~
scales.cpp:27:11: warning: unused variable 'fpos' [-Wunused-variable]
   27 |  int epos,fpos;
      |           ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...