Submission #134573

# Submission time Handle Problem Language Result Execution time Memory
134573 2019-07-23T04:18:50 Z StevenH Scales (IOI15_scales) C++14
0 / 100
2 ms 380 KB
#include "scales.h"
#include <cstring>
#include <array>
using namespace std;
void init(int T) {
    /* ... */
}


array<int,6> W;
void orderCoins() {

	int s[10];
	int a[4],b[4];

	memset(s,0,sizeof(s));
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));

	a[1]=getLightest(1,2,4);
	s[a[1]]=1;
	a[3]=getHeaviest(1,2,4);
	s[a[3]]=1;
	if(s[1]==0)a[2]=1;
	else if(s[2]==0)a[2]=2;
	else if(s[4]==0)a[2]=4;
	
	b[1]=getLightest(3,5,6);
	s[b[1]]=1;
	b[3]=getHeaviest(3,5,6);
	s[b[3]]=1;
	if(s[3]==0)b[2]=3;
	else if(s[5]==0)b[2]=5;
	else if(s[6]==0)b[2]=6;

	int id1,id2;
	//int w[6]={0,0,0,0,0,0},W=w;

	int res=getMedian(a[1],a[2],b[1]);
	if(res==a[1])id1=3;
	else if(res==a[2])id1=1;
	else if(res==b[1])id1=2;

	res=getMedian(a[3],b[2],b[3]);
	if(res==a[3])id2=3;
	else if(res==b[2])id2=1;
	else if(res==b[3])id2=2;

	
	int ans[6];
	if(id1==1 && id2==1)
	{
		int res=getMedian(a[2],b[1],a[3]);
		if(res==a[3])array<int,6> w={1,2,4,3,5,6},W=w;
		else if(res==b[1])array<int,6> w={1,2,3,4,5,6},W=w;
		for(int i=0;i<6;i++)
		{
			//printf("%d/",W[i]);
			int res;
			if(W[i]==1)res=a[1];
			if(W[i]==2)res=a[2];
			if(W[i]==3)res=a[3];
			if(W[i]==4)res=b[1];
			if(W[i]==5)res=b[2];
			if(W[i]==6)res=b[3];
			ans[i]=res;
		}
		
	}
	if(id1==1 && id2==2)
	{
		array<int,6> w={1,2,3,5,4,6},W=w;
		for(int i=0;i<6;i++)
		{
			//printf("%d/",W[i]);
			int res;
			if(W[i]==1)res=a[1];
			if(W[i]==2)res=a[2];
			if(W[i]==3)res=a[3];
			if(W[i]==4)res=b[1];
			if(W[i]==5)res=b[2];
			if(W[i]==6)res=b[3];
			ans[i]=res;
		}
	}	
	if(id1==1 && id2==3)
	{
		array<int,6> w={1,2,3,5,6,4},W=w;
		for(int i=0;i<6;i++)
		{
			//printf("%d/",W[i]);
			int res;
			if(W[i]==1)res=a[1];
			if(W[i]==2)res=a[2];
			if(W[i]==3)res=a[3];
			if(W[i]==4)res=b[1];
			if(W[i]==5)res=b[2];
			if(W[i]==6)res=b[3];
			ans[i]=res;
		}	
	}	
	if(id1==2 && id2==1)
	{
		array<int,6> w={1,3,2,4,5,6},W=w;
		for(int i=0;i<6;i++)
		{
			//printf("%d/",W[i]);
			int res;
			if(W[i]==1)res=a[1];
			if(W[i]==2)res=a[2];
			if(W[i]==3)res=a[3];
			if(W[i]==4)res=b[1];
			if(W[i]==5)res=b[2];
			if(W[i]==6)res=b[3];
			ans[i]=res;
		}
	}	
	if(id1==2 && id2==2)
	{
		res=getMedian(a[2],b[1],b[2]);
		if(res==b[2])array<int,6> w={1,3,5,2,4,6},W=w;
		else if(res==a[2])array<int,6> w={1,3,2,5,4,6},W=w;
		for(int i=0;i<6;i++)
		{
			//printf("%d/",W[i]);
			int res;
			if(W[i]==1)res=a[1];
			if(W[i]==2)res=a[2];
			if(W[i]==3)res=a[3];
			if(W[i]==4)res=b[1];
			if(W[i]==5)res=b[2];
			if(W[i]==6)res=b[3];
			ans[i]=res;
		}
	}	
	if(id1==2 && id2==3)
	{
		res=getMedian(a[2],b[2],b[3]);
		if(res==a[2])array<int,6> w={1,3,5,2,6,4},W=w;
		else if(res==b[2])array<int,6> w={1,3,2,5,6,4},W=w;
		else if(res==b[3])array<int,6> w={1,3,5,6,2,4},W=w;
		for(int i=0;i<6;i++)
		{
			//printf("%d/",W[i]);
			int res;
			if(W[i]==1)res=a[1];
			if(W[i]==2)res=a[2];
			if(W[i]==3)res=a[3];
			if(W[i]==4)res=b[1];
			if(W[i]==5)res=b[2];
			if(W[i]==6)res=b[3];
			ans[i]=res;
		}
	}	
	if(id1==3 && id2==1)
	{
		array<int,6> w={3,1,2,4,5,6},W=w;
		for(int i=0;i<6;i++)
		{
			//printf("%d/",W[i]);
			int res;
			if(W[i]==1)res=a[1];
			if(W[i]==2)res=a[2];
			if(W[i]==3)res=a[3];
			if(W[i]==4)res=b[1];
			if(W[i]==5)res=b[2];
			if(W[i]==6)res=b[3];
			ans[i]=res;
		}
	}
	if(id1==3 && id2==2)
	{
		int k[6];
		res=getMedian(a[1],a[2],b[2]);
		if(res==a[1])array<int,6> w={3,5,1,2,4,6},W=w;
		else if(res==a[2])array<int,6> w={3,1,2,5,4,6},W=w;
		else if(res==b[2])array<int,6> w={3,1,5,2,4,6},W=w;
		for(int i=0;i<6;i++)
		{
			//printf("%d/",W[i]);
			int res;
			if(W[i]==1)res=a[1];
			if(W[i]==2)res=a[2];
			if(W[i]==3)res=a[3];
			if(W[i]==4)res=b[1];
			if(W[i]==5)res=b[2];
			if(W[i]==6)res=b[3];
			ans[i]=res;
		}
	}	
	if(id1==3 && id2==3)
	{
		//res=getNextLightest(a[1],b[1],b[2],a[2]);
		//if(res==b[2])array<int,6> w={3,1,2,5,6,4},W=w;
		//else if(res==)
		array<int,6> w={3,1,2,5,6,4},W=w;
		//printf("%d %d %d %d %d %d %d\n",a[1],a[2],a[3],b[1],b[2],b[3],res);
		for(int i=0;i<6;i++)
		{
			//printf("%d/",W[i]);
			int res;
			if(W[i]==1)res=a[1];
			if(W[i]==2)res=a[2];
			if(W[i]==3)res=a[3];
			if(W[i]==4)res=b[1];
			if(W[i]==5)res=b[2];
			if(W[i]==6)res=b[3];
			ans[i]=res;
		}
	}
	
	answer(ans);
}

Compilation message

scales.cpp: In function 'void init(int)':
scales.cpp:5:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T) {
               ^
scales.cpp: In function 'void orderCoins()':
scales.cpp:53:7: warning: declaration of 'res' shadows a previous local [-Wshadow]
   int res=getMedian(a[2],b[1],a[3]);
       ^~~
scales.cpp:39:6: note: shadowed declaration is here
  int res=getMedian(a[1],a[2],b[1]);
      ^~~
scales.cpp:54:45: warning: declaration of 'W' shadows a global declaration [-Wshadow]
   if(res==a[3])array<int,6> w={1,2,4,3,5,6},W=w;
                                             ^
scales.cpp:10:14: note: shadowed declaration is here
 array<int,6> W;
              ^
scales.cpp:54:45: warning: variable 'W' set but not used [-Wunused-but-set-variable]
   if(res==a[3])array<int,6> w={1,2,4,3,5,6},W=w;
                                             ^
scales.cpp:55:50: warning: declaration of 'W' shadows a global declaration [-Wshadow]
   else if(res==b[1])array<int,6> w={1,2,3,4,5,6},W=w;
                                                  ^
scales.cpp:10:14: note: shadowed declaration is here
 array<int,6> W;
              ^
scales.cpp:55:50: warning: variable 'W' set but not used [-Wunused-but-set-variable]
   else if(res==b[1])array<int,6> w={1,2,3,4,5,6},W=w;
                                                  ^
scales.cpp:59:8: warning: declaration of 'res' shadows a previous local [-Wshadow]
    int res;
        ^~~
scales.cpp:53:7: note: shadowed declaration is here
   int res=getMedian(a[2],b[1],a[3]);
       ^~~
scales.cpp:72:32: warning: declaration of 'W' shadows a global declaration [-Wshadow]
   array<int,6> w={1,2,3,5,4,6},W=w;
                                ^
scales.cpp:10:14: note: shadowed declaration is here
 array<int,6> W;
              ^
scales.cpp:76:8: warning: declaration of 'res' shadows a previous local [-Wshadow]
    int res;
        ^~~
scales.cpp:39:6: note: shadowed declaration is here
  int res=getMedian(a[1],a[2],b[1]);
      ^~~
scales.cpp:88:32: warning: declaration of 'W' shadows a global declaration [-Wshadow]
   array<int,6> w={1,2,3,5,6,4},W=w;
                                ^
scales.cpp:10:14: note: shadowed declaration is here
 array<int,6> W;
              ^
scales.cpp:92:8: warning: declaration of 'res' shadows a previous local [-Wshadow]
    int res;
        ^~~
scales.cpp:39:6: note: shadowed declaration is here
  int res=getMedian(a[1],a[2],b[1]);
      ^~~
scales.cpp:104:32: warning: declaration of 'W' shadows a global declaration [-Wshadow]
   array<int,6> w={1,3,2,4,5,6},W=w;
                                ^
scales.cpp:10:14: note: shadowed declaration is here
 array<int,6> W;
              ^
scales.cpp:108:8: warning: declaration of 'res' shadows a previous local [-Wshadow]
    int res;
        ^~~
scales.cpp:39:6: note: shadowed declaration is here
  int res=getMedian(a[1],a[2],b[1]);
      ^~~
scales.cpp:121:45: warning: declaration of 'W' shadows a global declaration [-Wshadow]
   if(res==b[2])array<int,6> w={1,3,5,2,4,6},W=w;
                                             ^
scales.cpp:10:14: note: shadowed declaration is here
 array<int,6> W;
              ^
scales.cpp:121:45: warning: variable 'W' set but not used [-Wunused-but-set-variable]
   if(res==b[2])array<int,6> w={1,3,5,2,4,6},W=w;
                                             ^
scales.cpp:122:50: warning: declaration of 'W' shadows a global declaration [-Wshadow]
   else if(res==a[2])array<int,6> w={1,3,2,5,4,6},W=w;
                                                  ^
scales.cpp:10:14: note: shadowed declaration is here
 array<int,6> W;
              ^
scales.cpp:122:50: warning: variable 'W' set but not used [-Wunused-but-set-variable]
   else if(res==a[2])array<int,6> w={1,3,2,5,4,6},W=w;
                                                  ^
scales.cpp:126:8: warning: declaration of 'res' shadows a previous local [-Wshadow]
    int res;
        ^~~
scales.cpp:39:6: note: shadowed declaration is here
  int res=getMedian(a[1],a[2],b[1]);
      ^~~
scales.cpp:139:45: warning: declaration of 'W' shadows a global declaration [-Wshadow]
   if(res==a[2])array<int,6> w={1,3,5,2,6,4},W=w;
                                             ^
scales.cpp:10:14: note: shadowed declaration is here
 array<int,6> W;
              ^
scales.cpp:139:45: warning: variable 'W' set but not used [-Wunused-but-set-variable]
   if(res==a[2])array<int,6> w={1,3,5,2,6,4},W=w;
                                             ^
scales.cpp:140:50: warning: declaration of 'W' shadows a global declaration [-Wshadow]
   else if(res==b[2])array<int,6> w={1,3,2,5,6,4},W=w;
                                                  ^
scales.cpp:10:14: note: shadowed declaration is here
 array<int,6> W;
              ^
scales.cpp:140:50: warning: variable 'W' set but not used [-Wunused-but-set-variable]
   else if(res==b[2])array<int,6> w={1,3,2,5,6,4},W=w;
                                                  ^
scales.cpp:141:50: warning: declaration of 'W' shadows a global declaration [-Wshadow]
   else if(res==b[3])array<int,6> w={1,3,5,6,2,4},W=w;
                                                  ^
scales.cpp:10:14: note: shadowed declaration is here
 array<int,6> W;
              ^
scales.cpp:141:50: warning: variable 'W' set but not used [-Wunused-but-set-variable]
   else if(res==b[3])array<int,6> w={1,3,5,6,2,4},W=w;
                                                  ^
scales.cpp:145:8: warning: declaration of 'res' shadows a previous local [-Wshadow]
    int res;
        ^~~
scales.cpp:39:6: note: shadowed declaration is here
  int res=getMedian(a[1],a[2],b[1]);
      ^~~
scales.cpp:157:32: warning: declaration of 'W' shadows a global declaration [-Wshadow]
   array<int,6> w={3,1,2,4,5,6},W=w;
                                ^
scales.cpp:10:14: note: shadowed declaration is here
 array<int,6> W;
              ^
scales.cpp:161:8: warning: declaration of 'res' shadows a previous local [-Wshadow]
    int res;
        ^~~
scales.cpp:39:6: note: shadowed declaration is here
  int res=getMedian(a[1],a[2],b[1]);
      ^~~
scales.cpp:175:45: warning: declaration of 'W' shadows a global declaration [-Wshadow]
   if(res==a[1])array<int,6> w={3,5,1,2,4,6},W=w;
                                             ^
scales.cpp:10:14: note: shadowed declaration is here
 array<int,6> W;
              ^
scales.cpp:175:45: warning: variable 'W' set but not used [-Wunused-but-set-variable]
   if(res==a[1])array<int,6> w={3,5,1,2,4,6},W=w;
                                             ^
scales.cpp:176:50: warning: declaration of 'W' shadows a global declaration [-Wshadow]
   else if(res==a[2])array<int,6> w={3,1,2,5,4,6},W=w;
                                                  ^
scales.cpp:10:14: note: shadowed declaration is here
 array<int,6> W;
              ^
scales.cpp:176:50: warning: variable 'W' set but not used [-Wunused-but-set-variable]
   else if(res==a[2])array<int,6> w={3,1,2,5,4,6},W=w;
                                                  ^
scales.cpp:177:50: warning: declaration of 'W' shadows a global declaration [-Wshadow]
   else if(res==b[2])array<int,6> w={3,1,5,2,4,6},W=w;
                                                  ^
scales.cpp:10:14: note: shadowed declaration is here
 array<int,6> W;
              ^
scales.cpp:177:50: warning: variable 'W' set but not used [-Wunused-but-set-variable]
   else if(res==b[2])array<int,6> w={3,1,5,2,4,6},W=w;
                                                  ^
scales.cpp:181:8: warning: declaration of 'res' shadows a previous local [-Wshadow]
    int res;
        ^~~
scales.cpp:39:6: note: shadowed declaration is here
  int res=getMedian(a[1],a[2],b[1]);
      ^~~
scales.cpp:173:7: warning: unused variable 'k' [-Wunused-variable]
   int k[6];
       ^
scales.cpp:196:32: warning: declaration of 'W' shadows a global declaration [-Wshadow]
   array<int,6> w={3,1,2,5,6,4},W=w;
                                ^
scales.cpp:10:14: note: shadowed declaration is here
 array<int,6> W;
              ^
scales.cpp:201:8: warning: declaration of 'res' shadows a previous local [-Wshadow]
    int res;
        ^~~
scales.cpp:39:6: note: shadowed declaration is here
  int res=getMedian(a[1],a[2],b[1]);
      ^~~
scales.cpp:36:6: warning: 'id1' may be used uninitialized in this function [-Wmaybe-uninitialized]
  int id1,id2;
      ^~~
scales.cpp:51:18: warning: 'id2' may be used uninitialized in this function [-Wmaybe-uninitialized]
  if(id1==1 && id2==1)
               ~~~^~~
scales.cpp:208:10: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
    ans[i]=res;
    ~~~~~~^~~~
scales.cpp:188:10: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
    ans[i]=res;
    ~~~~~~^~~~
scales.cpp:168:10: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
    ans[i]=res;
    ~~~~~~^~~~
scales.cpp:152:10: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
    ans[i]=res;
    ~~~~~~^~~~
scales.cpp:133:10: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
    ans[i]=res;
    ~~~~~~^~~~
scales.cpp:66:10: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
    ans[i]=res;
    ~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Incorrect 2 ms 376 KB Output isn't correct
10 Incorrect 2 ms 376 KB Output isn't correct
11 Incorrect 2 ms 256 KB Output isn't correct
12 Incorrect 2 ms 376 KB Output isn't correct
13 Incorrect 2 ms 256 KB Output isn't correct
14 Incorrect 2 ms 256 KB Output isn't correct
15 Incorrect 2 ms 376 KB Output isn't correct
16 Incorrect 2 ms 376 KB Output isn't correct
17 Incorrect 2 ms 256 KB Output isn't correct
18 Incorrect 2 ms 376 KB Output isn't correct
19 Incorrect 2 ms 376 KB Output isn't correct
20 Incorrect 2 ms 380 KB Output isn't correct
21 Incorrect 2 ms 376 KB Output isn't correct
22 Incorrect 2 ms 256 KB Output isn't correct
23 Incorrect 2 ms 376 KB Output isn't correct
24 Incorrect 2 ms 376 KB Output isn't correct
25 Incorrect 2 ms 376 KB Output isn't correct
26 Incorrect 2 ms 376 KB Output isn't correct
27 Incorrect 2 ms 376 KB Output isn't correct
28 Incorrect 2 ms 256 KB Output isn't correct
29 Incorrect 2 ms 376 KB Output isn't correct
30 Incorrect 2 ms 376 KB Output isn't correct
31 Incorrect 2 ms 256 KB Output isn't correct
32 Incorrect 2 ms 256 KB Output isn't correct
33 Incorrect 2 ms 376 KB Output isn't correct
34 Incorrect 2 ms 376 KB Output isn't correct
35 Incorrect 2 ms 256 KB Output isn't correct
36 Incorrect 2 ms 376 KB Output isn't correct
37 Incorrect 2 ms 376 KB Output isn't correct
38 Incorrect 2 ms 376 KB Output isn't correct
39 Incorrect 2 ms 376 KB Output isn't correct
40 Incorrect 2 ms 376 KB Output isn't correct