제출 #584841

#제출 시각아이디문제언어결과실행 시간메모리
584841krit3379저울 (IOI15_scales)C++17
71.73 / 100
143 ms520 KiB
#include<bits/stdc++.h> #include "scales.h" using namespace std; #define N 100005 #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") struct A{ int id,i,j,k,l; }upd; vector<A> vec; vector<vector<int>> per; vector<int> v; void init(int t){ v={0,1,2,3,4,5}; do{ per.push_back(v); }while(next_permutation(v.begin(),v.end())); } void orderCoins(){ int ma,m,m1,m2,i,j,k,l,a,b,c,d,c1,c2,c3,x; int ans[6]; vector<vector<int>> now=per,temp; while(now.size()>1){ ma=2e9; //case 1 for(i=0;i<6;i++)for(j=i+1;j<6;j++)for(k=j+1;k<6;k++){ c1=c2=c3=0; for(auto arr:now){ a=arr[i],b=arr[j],c=arr[k]; m=max({a,b,c}); if(m==a)c1++; else if(m==b)c2++; else c3++; } if(max({c1,c2,c3})<ma)ma=max({c1,c2,c3}),vec={{1,i,j,k}}; else if(max({c1,c2,c3})==ma)vec.push_back({1,i,j,k}); } //case 2 for(i=0;i<6;i++)for(j=i+1;j<6;j++)for(k=j+1;k<6;k++){ c1=c2=c3=0; for(auto arr:now){ a=arr[i],b=arr[j],c=arr[k]; m=min({a,b,c}); if(m==a)c1++; else if(m==b)c2++; else c3++; } if(max({c1,c2,c3})<ma)ma=max({c1,c2,c3}),vec={{2,i,j,k}}; else if(max({c1,c2,c3})==ma)vec.push_back({2,i,j,k}); } //case 3 for(i=0;i<6;i++)for(j=i+1;j<6;j++)for(k=j+1;k<6;k++){ c1=c2=c3=0; for(auto arr:now){ a=arr[i],b=arr[j],c=arr[k]; m1=min({a,b,c}); m2=max({a,b,c}); if(a!=m1&&a!=m2)c1++; else if(b!=m1&&b!=m2)c2++; else c3++; } if(max({c1,c2,c3})<ma)ma=max({c1,c2,c3}),vec={{3,i,j,k}}; else if(max({c1,c2,c3})==ma)vec.push_back({3,i,j,k}); } //case 4 for(i=0;i<6;i++)for(j=i+1;j<6;j++)for(k=j+1;k<6;k++)for(l=0;l<6;l++){ if(l==i||l==j||l==k)continue; c1=c2=c3=0; for(auto arr:now){ a=arr[i],b=arr[j],c=arr[k],d=arr[l]; vector<int> t={a,b,c}; sort(t.begin(),t.end()); if(arr[l]>t[2]||arr[l]<t[0]){ if(a==t[0])c1++; else if(b==t[0])c2++; else c3++; } else if(arr[l]<t[1]){ if(a==t[1])c1++; else if(b==t[1])c2++; else c3++; } else{ if(a==t[2])c1++; else if(b==t[2])c2++; else c3++; } } if(max({c1,c2,c3})<ma)ma=max({c1,c2,c3}),vec={{4,i,j,k,l}}; else if(max({c1,c2,c3})==ma)vec.push_back({4,i,j,k,l}); } upd=vec[rand()%vec.size()]; auto [op,i,j,k,l]=upd; if(op==1){ x=getHeaviest(i+1,j+1,k+1); x--; for(auto arr:now)if(arr[x]==max({arr[i],arr[j],arr[k]}))temp.push_back(arr); } else if(op==2){ x=getLightest(i+1,j+1,k+1); x--; for(auto arr:now)if(arr[x]==min({arr[i],arr[j],arr[k]}))temp.push_back(arr); } else if(op==3){ x=getMedian(i+1,j+1,k+1); x--; for(auto arr:now)if(arr[x]!=max({arr[i],arr[j],arr[k]})&&arr[x]!=min({arr[i],arr[j],arr[k]}))temp.push_back(arr); } else{ x=getNextLightest(i+1,j+1,k+1,l+1); x--; int sz=0; for(auto arr:now){ int t=1e9; if(arr[i]>arr[l])t=min(t,arr[i]); if(arr[j]>arr[l])t=min(t,arr[j]); if(arr[k]>arr[l])t=min(t,arr[k]); if((max({arr[i],arr[j],arr[k]})<arr[l]&&arr[x]==min({arr[i],arr[j],arr[k]}))||arr[x]==t)temp.push_back(arr); } } now=temp; temp.clear(); vec.clear(); } for(i=0;i<6;i++)ans[now[0][i]]=i+1; answer(ans); }

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

scales.cpp: In function 'void init(int)':
scales.cpp:16:15: warning: unused parameter 't' [-Wunused-parameter]
   16 | void init(int t){
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:39:68: warning: missing initializer for member 'A::l' [-Wmissing-field-initializers]
   39 |             if(max({c1,c2,c3})<ma)ma=max({c1,c2,c3}),vec={{1,i,j,k}};
      |                                                                    ^
scales.cpp:40:64: warning: missing initializer for member 'A::l' [-Wmissing-field-initializers]
   40 |             else if(max({c1,c2,c3})==ma)vec.push_back({1,i,j,k});
      |                                                                ^
scales.cpp:52:68: warning: missing initializer for member 'A::l' [-Wmissing-field-initializers]
   52 |             if(max({c1,c2,c3})<ma)ma=max({c1,c2,c3}),vec={{2,i,j,k}};
      |                                                                    ^
scales.cpp:53:64: warning: missing initializer for member 'A::l' [-Wmissing-field-initializers]
   53 |             else if(max({c1,c2,c3})==ma)vec.push_back({2,i,j,k});
      |                                                                ^
scales.cpp:66:68: warning: missing initializer for member 'A::l' [-Wmissing-field-initializers]
   66 |             if(max({c1,c2,c3})<ma)ma=max({c1,c2,c3}),vec={{3,i,j,k}};
      |                                                                    ^
scales.cpp:67:64: warning: missing initializer for member 'A::l' [-Wmissing-field-initializers]
   67 |             else if(max({c1,c2,c3})==ma)vec.push_back({3,i,j,k});
      |                                                                ^
scales.cpp:97:18: warning: declaration of 'i' shadows a previous local [-Wshadow]
   97 |         auto [op,i,j,k,l]=upd;
      |                  ^
scales.cpp:24:20: note: shadowed declaration is here
   24 |     int ma,m,m1,m2,i,j,k,l,a,b,c,d,c1,c2,c3,x;
      |                    ^
scales.cpp:97:20: warning: declaration of 'j' shadows a previous local [-Wshadow]
   97 |         auto [op,i,j,k,l]=upd;
      |                    ^
scales.cpp:24:22: note: shadowed declaration is here
   24 |     int ma,m,m1,m2,i,j,k,l,a,b,c,d,c1,c2,c3,x;
      |                      ^
scales.cpp:97:22: warning: declaration of 'k' shadows a previous local [-Wshadow]
   97 |         auto [op,i,j,k,l]=upd;
      |                      ^
scales.cpp:24:24: note: shadowed declaration is here
   24 |     int ma,m,m1,m2,i,j,k,l,a,b,c,d,c1,c2,c3,x;
      |                        ^
scales.cpp:97:24: warning: declaration of 'l' shadows a previous local [-Wshadow]
   97 |         auto [op,i,j,k,l]=upd;
      |                        ^
scales.cpp:24:26: note: shadowed declaration is here
   24 |     int ma,m,m1,m2,i,j,k,l,a,b,c,d,c1,c2,c3,x;
      |                          ^
scales.cpp:116:17: warning: unused variable 'sz' [-Wunused-variable]
  116 |             int sz=0;
      |                 ^~
scales.cpp:24:34: warning: variable 'd' set but not used [-Wunused-but-set-variable]
   24 |     int ma,m,m1,m2,i,j,k,l,a,b,c,d,c1,c2,c3,x;
      |                                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...