제출 #1030265

#제출 시각아이디문제언어결과실행 시간메모리
1030265vjudge1코알라 (APIO17_koala)C++17
59 / 100
51 ms708 KiB
#include "koala.h" #include<bits/stdc++.h> using namespace std; mt19937 rng(243987); int minValue(int N, int W) { int me[100]{1},you[100]; playRound(me,you); for(int i=0;i<N;i++) if(you[i]==0) return i; return 0; } int maxValue(int N, int W) { int me[100],you[100]; vector<int>theposs(N); iota(theposs.begin(),theposs.end(),0); while(theposs.size()>1){ memset(me,0,sizeof me); for(auto i:theposs) me[i]=W/theposs.size(); playRound(me,you); vector<int>theposs2; for(auto i:theposs) if(you[i])theposs2.push_back(i); theposs=theposs2; } return theposs[0]; } int maxValue2(set<int>theposs, int W) { int me[100],you[100], ORIG=theposs.size(); while(theposs.size()>1){ memset(me,0,sizeof me); for(auto i:theposs) me[i]=(W+theposs.size()-ORIG)/theposs.size(); playRound(me,you); set<int>theposs2; for(auto i:theposs) if(you[i])theposs2.insert(i); theposs=theposs2; } return *theposs.begin(); } int greaterValue(int N, int W) { int me[100]{1,1},you[100]; int L=2,R=min(W/2,8); while(L<=R){ int mid=L+R>>1; me[0]=mid; me[1]=mid; playRound(me,you); if(you[0]-you[1]) return !you[0]; if(you[0]) L=mid+1; else R=mid-1; } }int greaterValue2(int A,int B) { int me[100]{},you[100]; int L=2,R=8; while(L<=R){ int mid=L+R>>1; me[A]=mid; me[B]=mid; playRound(me,you); if(you[A]-you[B]) return !you[A]; if(you[A]) L=mid+1; else R=mid-1; } me[A]=1,me[B]=1; playRound(me,you); return !you[A]; } void allValues(int N, int W, int *P) { vector<int>v(N); iota(v.begin(),v.end(),0); stable_sort(v.begin(),v.end(),[](int a,int b){ return !greaterValue2(a,b); }); for(int i=0;i<N;i++) P[v[i]]=N-i; }

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

koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:49:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   49 |         int mid=L+R>>1;
      |                 ~^~
koala.cpp: In function 'int greaterValue2(int, int)':
koala.cpp:63:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   63 |         int mid=L+R>>1;
      |                 ~^~
koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
   59 | }int greaterValue2(int A,int B) {
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...