Submission #166434

# Submission time Handle Problem Language Result Execution time Memory
166434 2019-12-02T12:25:36 Z dolphingarlic Koala Game (APIO17_koala) C++14
100 / 100
69 ms 760 KB
#include "koala.h"
#include <bits/stdc++.h>
#define e begin()
#define f end()
#define w vector<int>
using namespace std;int B[100],R[100];bool compare(int a,int b,int N,int W){fill(B,B+N,0);B[a]=B[b]=W;playRound(B,R);return(R[b]>W);}w g(w v,int N,int W){if(v.size()==1)return v;w a,b;a.insert(a.e,v.e,v.e+(v.size()+1)/2);b.insert(b.e,v.e+(v.size()+1)/2,v.f);a=g(a,N,W),b=g(b,N,W);w s;int a_=0,b_=0;while(a_<a.size()&&b_<b.size()){if(compare(a[a_],b[b_],N,W))s.push_back(a[a_++]);else s.push_back(b[b_++]);}s.insert(s.f,a.e+a_,a.f);s.insert(s.f,b.e+b_,b.f);return s;}void q(w v,int N,int W,int* P,int l=1,int r=100){if(l ==r)P[v[0]]=l;else{int x=min((int)sqrt(2 * l),W/(r-l+1));fill(B,B+N,0);for(int i:v)B[i]=x;playRound(B,R);w L,G;for(int i:v)if(R[i]>x)G.push_back(i);else L.push_back(i);q(L,N,W,P,l,l+L.size()-1);q(G,N,W,P,r-G.size()+1,r);}}int minValue(int N,int W){fill(B,B+N,0);B[0]=1;playRound(B,R);if(R[0]<2)return 0;else for(int i=1;i<N;i++)if(!R[i])return i;}int maxValue(int N,int W){w v;for(int i=0;i<N;i++)v.push_back(i);while(v.size()!=1){int k=W/v.size();fill(B,B+N,0);for(int i:v)B[i]=k;playRound(B,R);v.clear();for(int i=0;i<N;i++)if(R[i]>k)v.push_back(i);}return v[0];}int greaterValue(int N,int W){int l=1,r=9;while(l !=r){int m=(l+r)/2;B[0]=B[1]=m;playRound(B,R);if(R[0]>m &&R[1]>m)l=m+1;else if(R[0] <=m &&R[1] <=m)r=m-1;else return(R[0]<R[1]);}B[0]=B[1]=l;playRound(B,R);return(R[0]<R[1]);}void allValues(int N,int W,int *P){if(W ==2 * N){w v;for(int i=0;i<N;i++)v.push_back(i);w s=g(v,N,W/2);for(int i=0;i<N;i++)P[s[i]]=i+1;} else{w v;for(int i=0;i<N;i++)v.push_back(i);q(v,N,W,P);}}

Compilation message

koala.cpp: In function 'std::vector<int> g(std::vector<int>, int, int)':
koala.cpp:6:307: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 using namespace std;int B[100],R[100];bool compare(int a,int b,int N,int W){fill(B,B+N,0);B[a]=B[b]=W;playRound(B,R);return(R[b]>W);}w g(w v,int N,int W){if(v.size()==1)return v;w a,b;a.insert(a.e,v.e,v.e+(v.size()+1)/2);b.insert(b.e,v.e+(v.size()+1)/2,v.f);a=g(a,N,W),b=g(b,N,W);w s;int a_=0,b_=0;while(a_<a.size()&&b_<b.size()){if(compare(a[a_],b[b_],N,W))s.push_back(a[a_++]);else s.push_back(b[b_++]);}s.insert(s.f,a.e+a_,a.f);s.insert(s.f,b.e+b_,b.f);return s;}void q(w v,int N,int W,int* P,int l=1,int r=100){if(l ==r)P[v[0]]=l;else{int x=min((int)sqrt(2 * l),W/(r-l+1));fill(B,B+N,0);for(int i:v)B[i]=x;playRound(B,R);w L,G;for(int i:v)if(R[i]>x)G.push_back(i);else L.push_back(i);q(L,N,W,P,l,l+L.size()-1);q(G,N,W,P,r-G.size()+1,r);}}int minValue(int N,int W){fill(B,B+N,0);B[0]=1;playRound(B,R);if(R[0]<2)return 0;else for(int i=1;i<N;i++)if(!R[i])return i;}int maxValue(int N,int W){w v;for(int i=0;i<N;i++)v.push_back(i);while(v.size()!=1){int k=W/v.size();fill(B,B+N,0);for(int i:v)B[i]=k;playRound(B,R);v.clear();for(int i=0;i<N;i++)if(R[i]>k)v.push_back(i);}return v[0];}int greaterValue(int N,int W){int l=1,r=9;while(l !=r){int m=(l+r)/2;B[0]=B[1]=m;playRound(B,R);if(R[0]>m &&R[1]>m)l=m+1;else if(R[0] <=m &&R[1] <=m)r=m-1;else return(R[0]<R[1]);}B[0]=B[1]=l;playRound(B,R);return(R[0]<R[1]);}void allValues(int N,int W,int *P){if(W ==2 * N){w v;for(int i=0;i<N;i++)v.push_back(i);w s=g(v,N,W/2);for(int i=0;i<N;i++)P[s[i]]=i+1;} else{w v;for(int i=0;i<N;i++)v.push_back(i);q(v,N,W,P);}}
                                                                                                                                                                                                                                                                                                                 ~~^~~~~~~~~
koala.cpp:6:320: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 using namespace std;int B[100],R[100];bool compare(int a,int b,int N,int W){fill(B,B+N,0);B[a]=B[b]=W;playRound(B,R);return(R[b]>W);}w g(w v,int N,int W){if(v.size()==1)return v;w a,b;a.insert(a.e,v.e,v.e+(v.size()+1)/2);b.insert(b.e,v.e+(v.size()+1)/2,v.f);a=g(a,N,W),b=g(b,N,W);w s;int a_=0,b_=0;while(a_<a.size()&&b_<b.size()){if(compare(a[a_],b[b_],N,W))s.push_back(a[a_++]);else s.push_back(b[b_++]);}s.insert(s.f,a.e+a_,a.f);s.insert(s.f,b.e+b_,b.f);return s;}void q(w v,int N,int W,int* P,int l=1,int r=100){if(l ==r)P[v[0]]=l;else{int x=min((int)sqrt(2 * l),W/(r-l+1));fill(B,B+N,0);for(int i:v)B[i]=x;playRound(B,R);w L,G;for(int i:v)if(R[i]>x)G.push_back(i);else L.push_back(i);q(L,N,W,P,l,l+L.size()-1);q(G,N,W,P,r-G.size()+1,r);}}int minValue(int N,int W){fill(B,B+N,0);B[0]=1;playRound(B,R);if(R[0]<2)return 0;else for(int i=1;i<N;i++)if(!R[i])return i;}int maxValue(int N,int W){w v;for(int i=0;i<N;i++)v.push_back(i);while(v.size()!=1){int k=W/v.size();fill(B,B+N,0);for(int i:v)B[i]=k;playRound(B,R);v.clear();for(int i=0;i<N;i++)if(R[i]>k)v.push_back(i);}return v[0];}int greaterValue(int N,int W){int l=1,r=9;while(l !=r){int m=(l+r)/2;B[0]=B[1]=m;playRound(B,R);if(R[0]>m &&R[1]>m)l=m+1;else if(R[0] <=m &&R[1] <=m)r=m-1;else return(R[0]<R[1]);}B[0]=B[1]=l;playRound(B,R);return(R[0]<R[1]);}void allValues(int N,int W,int *P){if(W ==2 * N){w v;for(int i=0;i<N;i++)v.push_back(i);w s=g(v,N,W/2);for(int i=0;i<N;i++)P[s[i]]=i+1;} else{w v;for(int i=0;i<N;i++)v.push_back(i);q(v,N,W,P);}}
                                                                                                                                                                                                                                                                                                                              ~~^~~~~~~~~
koala.cpp: In function 'int minValue(int, int)':
koala.cpp:6:867: warning: control reaches end of non-void function [-Wreturn-type]
 using namespace std;int B[100],R[100];bool compare(int a,int b,int N,int W){fill(B,B+N,0);B[a]=B[b]=W;playRound(B,R);return(R[b]>W);}w g(w v,int N,int W){if(v.size()==1)return v;w a,b;a.insert(a.e,v.e,v.e+(v.size()+1)/2);b.insert(b.e,v.e+(v.size()+1)/2,v.f);a=g(a,N,W),b=g(b,N,W);w s;int a_=0,b_=0;while(a_<a.size()&&b_<b.size()){if(compare(a[a_],b[b_],N,W))s.push_back(a[a_++]);else s.push_back(b[b_++]);}s.insert(s.f,a.e+a_,a.f);s.insert(s.f,b.e+b_,b.f);return s;}void q(w v,int N,int W,int* P,int l=1,int r=100){if(l ==r)P[v[0]]=l;else{int x=min((int)sqrt(2 * l),W/(r-l+1));fill(B,B+N,0);for(int i:v)B[i]=x;playRound(B,R);w L,G;for(int i:v)if(R[i]>x)G.push_back(i);else L.push_back(i);q(L,N,W,P,l,l+L.size()-1);q(G,N,W,P,r-G.size()+1,r);}}int minValue(int N,int W){fill(B,B+N,0);B[0]=1;playRound(B,R);if(R[0]<2)return 0;else for(int i=1;i<N;i++)if(!R[i])return i;}int maxValue(int N,int W){w v;for(int i=0;i<N;i++)v.push_back(i);while(v.size()!=1){int k=W/v.size();fill(B,B+N,0);for(int i:v)B[i]=k;playRound(B,R);v.clear();for(int i=0;i<N;i++)if(R[i]>k)v.push_back(i);}return v[0];}int greaterValue(int N,int W){int l=1,r=9;while(l !=r){int m=(l+r)/2;B[0]=B[1]=m;playRound(B,R);if(R[0]>m &&R[1]>m)l=m+1;else if(R[0] <=m &&R[1] <=m)r=m-1;else return(R[0]<R[1]);}B[0]=B[1]=l;playRound(B,R);return(R[0]<R[1]);}void allValues(int N,int W,int *P){if(W ==2 * N){w v;for(int i=0;i<N;i++)v.push_back(i);w s=g(v,N,W/2);for(int i=0;i<N;i++)P[s[i]]=i+1;} else{w v;for(int i=0;i<N;i++)v.push_back(i);q(v,N,W,P);}}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ^
# Verdict Execution time Memory Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 376 KB Output is correct
2 Correct 17 ms 376 KB Output is correct
3 Correct 17 ms 504 KB Output is correct
4 Correct 16 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 632 KB Output is correct
2 Correct 69 ms 376 KB Output is correct
3 Correct 59 ms 760 KB Output is correct
4 Correct 59 ms 760 KB Output is correct
5 Correct 60 ms 760 KB Output is correct
6 Correct 60 ms 760 KB Output is correct
7 Correct 60 ms 760 KB Output is correct
8 Correct 61 ms 752 KB Output is correct
9 Correct 61 ms 760 KB Output is correct
10 Correct 59 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 376 KB Output is correct
2 Correct 35 ms 424 KB Output is correct
3 Correct 34 ms 376 KB Output is correct
4 Correct 34 ms 376 KB Output is correct
5 Correct 33 ms 384 KB Output is correct
6 Correct 34 ms 376 KB Output is correct
7 Correct 34 ms 248 KB Output is correct
8 Correct 33 ms 376 KB Output is correct
9 Correct 33 ms 376 KB Output is correct
10 Correct 32 ms 484 KB Output is correct
11 Correct 34 ms 376 KB Output is correct
12 Correct 20 ms 376 KB Output is correct
13 Correct 34 ms 376 KB Output is correct
14 Correct 31 ms 376 KB Output is correct
15 Correct 31 ms 376 KB Output is correct
16 Correct 30 ms 376 KB Output is correct
17 Correct 31 ms 376 KB Output is correct
18 Correct 26 ms 388 KB Output is correct
19 Correct 31 ms 380 KB Output is correct
20 Correct 32 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 5 ms 380 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 5 ms 396 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 7 ms 348 KB Output is correct
21 Correct 5 ms 380 KB Output is correct
22 Correct 11 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 380 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 380 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 5 ms 388 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
33 Correct 5 ms 380 KB Output is correct
34 Correct 5 ms 376 KB Output is correct
35 Correct 5 ms 380 KB Output is correct
36 Correct 5 ms 376 KB Output is correct
37 Correct 5 ms 376 KB Output is correct
38 Correct 12 ms 376 KB Output is correct
39 Correct 5 ms 376 KB Output is correct
40 Correct 8 ms 376 KB Output is correct