제출 #204064

#제출 시각아이디문제언어결과실행 시간메모리
204064Segtree저울 (IOI15_scales)C++14
55.56 / 100
6 ms376 KiB
#include"scales.h" #include<iostream> #include<algorithm> #include<vector> using namespace std; typedef long long ll; typedef pair<ll,ll> P; #define chmin(a,b) a=min(a,b) #define chmax(a,b) a=max(a,b) #define rep(i,n) for(int i=0;i<n;i++) #define mod 1000000007 #define mad(a,b) a=(a+b)%mod /*int VALUE[6]; int getLightest(int a,int b,int c){ a--,b--,c--; vector<P> v; v.push_back(make_pair(VALUE[a],a)); v.push_back(make_pair(VALUE[b],b)); v.push_back(make_pair(VALUE[c],c)); sort(v.begin(),v.end()); return v[0].second+1; } int getMedian(int a,int b,int c){ a--,b--,c--; vector<P> v; v.push_back(make_pair(VALUE[a],a)); v.push_back(make_pair(VALUE[b],b)); v.push_back(make_pair(VALUE[c],c)); sort(v.begin(),v.end()); return v[1].second+1; } int getHeaviest(int a,int b,int c){ a--,b--,c--; vector<P> v; v.push_back(make_pair(VALUE[a],a)); v.push_back(make_pair(VALUE[b],b)); v.push_back(make_pair(VALUE[c],c)); sort(v.begin(),v.end()); return v[2].second+1; } int getNextLightest(int a,int b,int c,int d){ a--,b--,c--,d--; vector<P> v; v.push_back(make_pair(VALUE[a],a)); v.push_back(make_pair(VALUE[b],b)); v.push_back(make_pair(VALUE[c],c)); v.push_back(make_pair(VALUE[d],d)); sort(v.begin(),v.end()); rep(i,4)if(v[i].second==d){ return v[(i+1)%4].second+1; } } void answer(int w[]){ rep(i,6)cout<<w[i]<<" "; cout<<endl; }*/ void init(int T){ return; } void orderCoins(){ int w[6]; vector<ll> a; rep(i,6)a.push_back(i+1); int v1=getNextLightest(a[1],a[2],a[3],a[0]); int v2=getNextLightest(v1,a[4],a[5],a[0]); w[0]=a[0],w[1]=v2; vector<ll> b; for(int i=1;i<=6;i++){ bool ok=1; rep(j,2)if(w[j]==i)ok=0; if(ok)b.push_back(i); } int v3=getNextLightest(b[0],b[1],b[2],w[1]); int v4=getNextLightest(v3,b[3],w[0],w[1]); w[2]=v4; vector<ll> c; for(int i=1;i<=6;i++){ bool ok=1; rep(j,3)if(w[j]==i)ok=0; if(ok)c.push_back(i); } int v5=getNextLightest(c[0],c[1],c[2],w[2]); w[3]=v5; vector<ll> d; for(int i=1;i<=6;i++){ bool ok=1; rep(j,4)if(w[j]==i)ok=0; if(ok)d.push_back(i); } int v6=getNextLightest(d[0],d[1],w[2],w[3]); w[4]=v6; for(int i=1;i<=6;i++){ bool ok=1; rep(j,5)if(w[j]==i)ok=0; if(ok)w[5]=i; } int v7=getLightest(w[0],w[2],w[4]); int v8; for(int i=0;i<=4;i+=2){ if(v7==w[i]){ int k1=w[(i+5)%6]; int k2=w[i]; int k3=w[(i+1)%6]; v8=getLightest(k1,k2,k3); break; } } int pnt=-1; rep(i,6)if(w[i]==v8)pnt=i; int ww[6]; rep(i,6)ww[(i-pnt+6)%6]=w[i]; answer(ww); }/* int main(){ init(10); rep(u,10){ rep(i,6)VALUE[i]=i; rep(u,100)swap(VALUE[rand()%6],VALUE[rand()%6]); orderCoins(); vector<P> v; rep(i,6)v.push_back(make_pair(VALUE[i],i+1)); sort(v.begin(),v.end()); rep(i,6)cout<<v[i].second<<" "; cout<<endl;cout<<"--"<<endl; } }*/

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

scales.cpp: In function 'void init(int)':
scales.cpp:57:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T){
               ^
scales.cpp: In function 'void orderCoins()':
scales.cpp:64:44: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
  int v1=getNextLightest(a[1],a[2],a[3],a[0]);
                                            ^
scales.cpp:64:44: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
scales.cpp:64:44: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
scales.cpp:64:44: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
scales.cpp:65:42: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
  int v2=getNextLightest(v1,a[4],a[5],a[0]);
                                          ^
scales.cpp:65:42: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
scales.cpp:65:42: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
scales.cpp:66:10: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
  w[0]=a[0],w[1]=v2;
          ^
scales.cpp:74:44: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
  int v3=getNextLightest(b[0],b[1],b[2],w[1]);
                                            ^
scales.cpp:74:44: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
scales.cpp:74:44: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
scales.cpp:75:42: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
  int v4=getNextLightest(v3,b[3],w[0],w[1]);
                                          ^
scales.cpp:84:44: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
  int v5=getNextLightest(c[0],c[1],c[2],w[2]);
                                            ^
scales.cpp:84:44: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
scales.cpp:84:44: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
scales.cpp:93:44: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
  int v6=getNextLightest(d[0],d[1],w[2],w[3]);
                                            ^
scales.cpp:93:44: warning: conversion to 'int' from '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}' may alter its value [-Wconversion]
scales.cpp:115:10: warning: 'v8' may be used uninitialized in this function [-Wmaybe-uninitialized]
  rep(i,6)if(w[i]==v8)pnt=i;
          ^~
#Verdict Execution timeMemoryGrader output
Fetching results...