답안 #409305

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
409305 2021-05-20T14:27:35 Z myrcella 코알라 (APIO17_koala) C++17
37 / 100
73 ms 348 KB
#include "koala.h"
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}


int a[100],b[100];

void playRound(int *B, int *R);

int minValue(int N, int W) {
    // TODO: Implement Subtask 1 solution here.
    // You may leave this function unmodified if you are not attempting this
    // subtask.
    memset(a,0,sizeof(a));
    a[0]=1;
    playRound(a,b);
    rep(i,0,N) if (b[i]<=a[i]) return i;
}

int flag[100];

int maxValue(int N, int W) {
    // TODO: Implement Subtask 2 solution here.
    // You may leave this function unmodified if you are not attempting this
    // subtask.
    memset(flag,0,sizeof(flag));
    rep(i,0,N) a[i]=1;
    playRound(a,b);
    rep(i,0,N) if (b[i]>a[i]) flag[i]++; else flag[i]=-233;
    rep(i,0,N) if (flag[i]==1) a[i]=2;else a[i]=0;
    playRound(a,b);
    rep(i,0,N) if (flag[i]==1&&b[i]>a[i]) flag[i]++; else flag[i]=-233;
    rep(i,0,N) if (flag[i]==2) a[i]=4;else a[i]=0;
    playRound(a,b);
    rep(i,0,N) if (flag[i]==2&&b[i]>a[i]) flag[i]++;
    rep(i,0,N) if (flag[i]==3) a[i]=11;else a[i]=0;
    playRound(a,b);
    rep(i,0,N) if (flag[i]==3&&b[i]>a[i]) return i;
    return 0;
}

int greaterValue(int N, int W) {
	int l=1,r=14;
//	while ((1+r)*r/2<N+N-1) r++; r--;
	memset(a,0,sizeof(a));
	while (l<r) {
		int mid=l+r>>1;
		a[0]=a[1]=mid;
		playRound(a,b);
		if (b[0]<=a[0]&&b[1]<=a[1]) r=mid-1;
		else if (b[0]>a[0]&&b[1]>a[1]) l=mid+1;
		else return b[0]>a[0]?0:1;
	}
    // TODO: Implement Subtask 3 solution here.
    // You may leave this function unmodified if you are not attempting this
    // subtask.
}

void allValues(int N, int W, int *P) {
    if (W == 2*N) {
        // TODO: Implement Subtask 4 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    } else {
        // TODO: Implement Subtask 5 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    }
}

Compilation message

koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:66:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   66 |   int mid=l+r>>1;
      |           ~^~
koala.cpp: In function 'int minValue(int, int)':
koala.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
   37 | }
      | ^
koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:76:1: warning: control reaches end of non-void function [-Wreturn-type]
   76 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 200 KB Output is correct
2 Correct 5 ms 200 KB Output is correct
3 Correct 5 ms 200 KB Output is correct
4 Correct 5 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 200 KB Output is correct
2 Correct 15 ms 312 KB Output is correct
3 Correct 20 ms 200 KB Output is correct
4 Correct 17 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 324 KB Output is correct
2 Correct 73 ms 324 KB Output is correct
3 Correct 49 ms 316 KB Output is correct
4 Correct 58 ms 320 KB Output is correct
5 Correct 53 ms 348 KB Output is correct
6 Correct 50 ms 328 KB Output is correct
7 Correct 50 ms 332 KB Output is correct
8 Correct 50 ms 320 KB Output is correct
9 Correct 53 ms 328 KB Output is correct
10 Correct 50 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 200 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 200 KB Output isn't correct
2 Halted 0 ms 0 KB -