Submission #134560

#TimeUsernameProblemLanguageResultExecution timeMemory
134560StevenHScales (IOI15_scales)C++14
0 / 100
3 ms504 KiB
#include "scales.h" #include <cstring> #include <array> using namespace std; void init(int T) { /* ... */ } void orderCoins() { int s[10]; int a[4],b[4]; memset(s,0,sizeof(s)); memset(a,0,sizeof(s)); memset(b,0,sizeof(s)); 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=1; else if(res==a[2])id1=2; else if(res==b[1])id1=3; res=getMedian(a[3],b[2],b[3]); if(res==a[3])id2=1; else if(res==b[2])id2=2; else if(res==b[3])id2=3; array<int,6> W; 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; } if(id1==1 && id2==2) { array<int,6> w={1,2,3,5,4,6},W=w; } if(id1==1 && id2==3) { array<int,6> w={1,2,3,5,6,4},W=w; } if(id1==2 && id2==1) { array<int,6> w={1,3,2,4,5,6},W=w; } 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; } 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; } if(id1==3 && id2==1) { array<int,6> w={3,1,2,4,5,6},W=w; } 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; } 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; } int ans[6]; for(int i=0;i<6;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 (stderr)

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:52:7: warning: declaration of 'res' shadows a previous local [-Wshadow]
   int res=getMedian(a[2],b[1],a[3]);
       ^~~
scales.cpp:38:6: note: shadowed declaration is here
  int res=getMedian(a[1],a[2],b[1]);
      ^~~
scales.cpp:53:45: warning: declaration of 'W' shadows a previous local [-Wshadow]
   if(res==a[3])array<int,6> w={1,2,4,3,5,6},W=w;
                                             ^
scales.cpp:49:15: note: shadowed declaration is here
  array<int,6> W;
               ^
scales.cpp:53: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:54:50: warning: declaration of 'W' shadows a previous local [-Wshadow]
   else if(res==b[1])array<int,6> w={1,2,3,4,5,6},W=w;
                                                  ^
scales.cpp:49:15: note: shadowed declaration is here
  array<int,6> W;
               ^
scales.cpp:54: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:58:32: warning: declaration of 'W' shadows a previous local [-Wshadow]
   array<int,6> w={1,2,3,5,4,6},W=w;
                                ^
scales.cpp:49:15: note: shadowed declaration is here
  array<int,6> W;
               ^
scales.cpp:58:32: warning: variable 'W' set but not used [-Wunused-but-set-variable]
   array<int,6> w={1,2,3,5,4,6},W=w;
                                ^
scales.cpp:62:32: warning: declaration of 'W' shadows a previous local [-Wshadow]
   array<int,6> w={1,2,3,5,6,4},W=w; 
                                ^
scales.cpp:49:15: note: shadowed declaration is here
  array<int,6> W;
               ^
scales.cpp:62:32: warning: variable 'W' set but not used [-Wunused-but-set-variable]
   array<int,6> w={1,2,3,5,6,4},W=w; 
                                ^
scales.cpp:66:32: warning: declaration of 'W' shadows a previous local [-Wshadow]
   array<int,6> w={1,3,2,4,5,6},W=w;
                                ^
scales.cpp:49:15: note: shadowed declaration is here
  array<int,6> W;
               ^
scales.cpp:66:32: warning: variable 'W' set but not used [-Wunused-but-set-variable]
   array<int,6> w={1,3,2,4,5,6},W=w;
                                ^
scales.cpp:71:45: warning: declaration of 'W' shadows a previous local [-Wshadow]
   if(res==b[2])array<int,6> w={1,3,5,2,4,6},W=w;
                                             ^
scales.cpp:49:15: note: shadowed declaration is here
  array<int,6> W;
               ^
scales.cpp:71: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:72:50: warning: declaration of 'W' shadows a previous local [-Wshadow]
   else if(res==a[2])array<int,6> w={1,3,2,5,4,6},W=w;
                                                  ^
scales.cpp:49:15: note: shadowed declaration is here
  array<int,6> W;
               ^
scales.cpp:72: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:77:45: warning: declaration of 'W' shadows a previous local [-Wshadow]
   if(res==a[2])array<int,6> w={1,3,5,2,6,4},W=w;
                                             ^
scales.cpp:49:15: note: shadowed declaration is here
  array<int,6> W;
               ^
scales.cpp:77: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:78:50: warning: declaration of 'W' shadows a previous local [-Wshadow]
   else if(res==b[2])array<int,6> w={1,3,2,5,6,4},W=w;
                                                  ^
scales.cpp:49:15: note: shadowed declaration is here
  array<int,6> W;
               ^
scales.cpp:78: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:79:50: warning: declaration of 'W' shadows a previous local [-Wshadow]
   else if(res==b[3])array<int,6> w={1,3,5,6,2,4},W=w;
                                                  ^
scales.cpp:49:15: note: shadowed declaration is here
  array<int,6> W;
               ^
scales.cpp:79: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:83:32: warning: declaration of 'W' shadows a previous local [-Wshadow]
   array<int,6> w={3,1,2,4,5,6},W=w;
                                ^
scales.cpp:49:15: note: shadowed declaration is here
  array<int,6> W;
               ^
scales.cpp:83:32: warning: variable 'W' set but not used [-Wunused-but-set-variable]
   array<int,6> w={3,1,2,4,5,6},W=w;
                                ^
scales.cpp:89:45: warning: declaration of 'W' shadows a previous local [-Wshadow]
   if(res==a[1])array<int,6> w={3,5,1,2,4,6},W=w;
                                             ^
scales.cpp:49:15: note: shadowed declaration is here
  array<int,6> W;
               ^
scales.cpp:89: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:90:50: warning: declaration of 'W' shadows a previous local [-Wshadow]
   else if(res==a[2])array<int,6> w={3,1,2,5,4,6},W=w;
                                                  ^
scales.cpp:49:15: note: shadowed declaration is here
  array<int,6> W;
               ^
scales.cpp:90: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:91:50: warning: declaration of 'W' shadows a previous local [-Wshadow]
   else if(res==b[2])array<int,6> w={3,1,5,2,4,6},W=w;
                                                  ^
scales.cpp:49:15: note: shadowed declaration is here
  array<int,6> W;
               ^
scales.cpp:91: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:87:7: warning: unused variable 'k' [-Wunused-variable]
   int k[6];
       ^
scales.cpp:98:32: warning: declaration of 'W' shadows a previous local [-Wshadow]
   array<int,6> w={3,1,2,5,6,4},W=w;
                                ^
scales.cpp:49:15: note: shadowed declaration is here
  array<int,6> W;
               ^
scales.cpp:98:32: warning: variable 'W' set but not used [-Wunused-but-set-variable]
   array<int,6> w={3,1,2,5,6,4},W=w;
                                ^
scales.cpp:104:7: warning: declaration of 'res' shadows a previous local [-Wshadow]
   int res;
       ^~~
scales.cpp:38:6: note: shadowed declaration is here
  int res=getMedian(a[1],a[2],b[1]);
      ^~~
scales.cpp:35:6: warning: 'id1' may be used uninitialized in this function [-Wmaybe-uninitialized]
  int id1,id2;
      ^~~
scales.cpp:105:10: warning: '#'target_mem_ref' not supported by dump_expr#<expression error>' is used uninitialized in this function [-Wuninitialized]
   if(W[i]==1)res=a[1];
scales.cpp:56:18: warning: 'id2' may be used uninitialized in this function [-Wmaybe-uninitialized]
  if(id1==1 && id2==2)
               ~~~^~~
scales.cpp:111:9: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
   ans[i]=res;
   ~~~~~~^~~~
In file included from /usr/include/string.h:635:0,
                 from /usr/include/c++/7/cstring:42,
                 from scales.cpp:2:
In function 'void* memset(void*, int, size_t)',
    inlined from 'void orderCoins()' at scales.cpp:16:8:
/usr/include/x86_64-linux-gnu/bits/string3.h:90:70: warning: 'void* __builtin___memset_chk(void*, int, long unsigned int, long unsigned int)' writing 40 bytes into a region of size 16 overflows the destination [-Wstringop-overflow=]
   return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
                                                                      ^
In function 'void* memset(void*, int, size_t)',
    inlined from 'void orderCoins()' at scales.cpp:17:8:
/usr/include/x86_64-linux-gnu/bits/string3.h:90:70: warning: 'void* __builtin___memset_chk(void*, int, long unsigned int, long unsigned int)' writing 40 bytes into a region of size 16 overflows the destination [-Wstringop-overflow=]
   return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
                                                                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...