이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "koala.h"
#include <bits/stdc++.h>
using namespace std;
const int Nmax = 105;
int a[Nmax], b[Nmax];
int minValue(int N, int W)
{
int i;
for(i=1; i<N; ++i) a[i] = 0;
a[1] = 1;
int id;
playRound(a, b);
for(i=0; i<N; ++i)
if(b[i] < a[i] + 1)
id = i;
return id;
}
int maxValue(int N, int W)
{
int i, step, nr = N;
bool used[Nmax];
for(i=0; i<N; ++i) used[i] = 1;
for(step = 0; step < 4; ++step)
{
for(i=0; i<N; ++i)
if(used[i]) a[i] = N / nr;
else a[i] = 0;
playRound(a, b);
for(i=0; i<N; ++i)
if(used[i] && b[i] <= a[i])
used[i] = 0, --nr;
}
assert(nr == 1);
for(i=0; i<N; ++i)
if(used[i]) return i;
assert(0);
}
bool cmp(int x, int y) /// 1 daca x < y;
{
if(x == y) return 0;
int l = 1, r = 9, mid;
while(1)
{
mid = (l + r) / 2;
int i;
for(i=0; i<100; ++i) a[i] = ((i == x || i == y) ? mid : 0);
playRound(a, b);
bool X, Y;
X = b[x] > a[x];
Y = b[y] > a[y];
if(X ^ Y)
return Y;
if(!X) r = mid - 1;
else l = mid + 1;
}
assert(0);
}
bool cmp2(int x, int y)
{
if(x == y) return 0;
int i;
for(i=0; i<100; ++i) a[i] = 0;
a[x] = a[y] = 100;
playRound(a, b);
return (a[y] < b[y]);
}
int greaterValue(int N, int W)
{
return (cmp(0, 1) ? 1 : 0);
}
void allValues(int N, int W, int *P)
{
int i;
for(i=0; i<N; ++i) P[i] = i;
int ans[Nmax];
if (W == 2*N)
sort(P, P+N, cmp2);
else
sort(P, P+N, cmp);
for(i=0; i<N; ++i)
ans[P[i]] = i+1;
for(i=0; i<N; ++i)
P[i] = ans[i];
}
컴파일 시 표준 에러 (stderr) 메시지
koala.cpp: In function 'int minValue(int, int)':
koala.cpp:21:12: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
return id;
^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |