답안 #978387

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978387 2024-05-09T07:44:29 Z oolimry 코알라 (APIO17_koala) C++17
66 / 100
48 ms 596 KB
#include "koala.h"
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int) x.size())
using namespace std;

int B[100]; int R[100];
int minValue(int N, int W) {
	fill(B,B+N,0); B[0] = 1;
    playRound(B,R);
    for(int i = 0;i < N;i++){
        if(R[i] == 0) return i;
    }
    return -1;
}

int big[105];
int maxValue(int n, int W) {
	fill(big,big+n,1);
	vector<int> witness = {};
	for(int x : witness){
		for(int i = 0;i < n;i++){
			if(big[i]) B[i] = x;
			else B[i] = 0;
		}
		playRound(B,R);
		
		for(int i = 0;i < n;i++){
			if(R[i] == 0) big[i] = 0;
		}
		
		for(int i = 0;i < n;i++) { cerr << R[i] << " "; } cerr << endl;
	}
	
	for(int i = 0;i < n;i++) if(big[i]) return i;
	return 0;
}

int greaterValue(int n, int W){
	int x = 0;
	for(int s = 8;s >= 1;s /= 2){
		x += s;
		
		B[0] = x;
		B[1] = x;
		playRound(B,R);
		
		if(R[0] > R[1]) return 0;
		if(R[1] > R[0]) return 1;
		if(R[0] == 0) x -= s;
	}
	return -1;
}

void allValues1(int n, int W, int *P){
	int B[n]; int R[n]; int A[n];
	for(int i = 0;i < n;i++) A[i] = i;
	
	stable_sort(A, A+n, [&](int a, int b){
		fill(B,B+n,0);
		B[a] = n, B[b] = n;
		playRound(B,R);

		if(R[a] == 0) return true;
		else return false;
	});
	
	for(int i = 0;i < n;i++) P[A[i]] = i+1;
}

void allValues2(int n, int *P, int s, int e, vector<int> stuff){
	if(sz(stuff) == 1){
		P[stuff[0]] = s;
		return;
	}
	
	for(int X = 1;X < 100;X++){
		fill(B,B+n,0);
		for(int i : stuff) B[i] = X;
		playRound(B,R);
		
		vector<int> left, right;
		for(int i : stuff){
			if(R[i] == 0) left.push_back(i);
			else right.push_back(i);
		}
		
		if(sz(left) != 0 and sz(right) != 0){
			int m = s + sz(left);
			allValues2(n, P, s, m-1, left);
			allValues2(n, P, m, e, right);
			return;
		}
	}
}

void allValues(int N, int W, int *P) {
    if (W == 2*N) allValues1(N, W, P);
    else{
		vector<int> stuff;
		for(int i = 0;i < N;i++) stuff.push_back(i);
		allValues2(N, P, 1, N, stuff);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 3 ms 456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 488 KB Output is correct
2 Partially correct 37 ms 496 KB Output is partially correct
3 Correct 38 ms 472 KB Output is correct
4 Correct 38 ms 460 KB Output is correct
5 Partially correct 35 ms 488 KB Output is partially correct
6 Correct 48 ms 468 KB Output is correct
7 Partially correct 37 ms 472 KB Output is partially correct
8 Correct 36 ms 472 KB Output is correct
9 Correct 34 ms 468 KB Output is correct
10 Correct 35 ms 472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 452 KB Output is correct
2 Correct 34 ms 456 KB Output is correct
3 Correct 28 ms 344 KB Output is correct
4 Correct 27 ms 344 KB Output is correct
5 Correct 27 ms 344 KB Output is correct
6 Correct 28 ms 456 KB Output is correct
7 Correct 28 ms 344 KB Output is correct
8 Correct 28 ms 452 KB Output is correct
9 Correct 27 ms 344 KB Output is correct
10 Correct 26 ms 344 KB Output is correct
11 Correct 29 ms 344 KB Output is correct
12 Correct 20 ms 344 KB Output is correct
13 Correct 26 ms 452 KB Output is correct
14 Correct 24 ms 452 KB Output is correct
15 Correct 25 ms 344 KB Output is correct
16 Correct 25 ms 456 KB Output is correct
17 Correct 26 ms 344 KB Output is correct
18 Correct 25 ms 344 KB Output is correct
19 Correct 29 ms 344 KB Output is correct
20 Correct 25 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 14 ms 344 KB Output is partially correct
2 Partially correct 14 ms 344 KB Output is partially correct
3 Partially correct 8 ms 344 KB Output is partially correct
4 Partially correct 9 ms 344 KB Output is partially correct
5 Partially correct 8 ms 460 KB Output is partially correct
6 Partially correct 8 ms 344 KB Output is partially correct
7 Partially correct 9 ms 460 KB Output is partially correct
8 Partially correct 9 ms 344 KB Output is partially correct
9 Partially correct 8 ms 344 KB Output is partially correct
10 Partially correct 8 ms 344 KB Output is partially correct
11 Partially correct 14 ms 344 KB Output is partially correct
12 Partially correct 14 ms 456 KB Output is partially correct
13 Partially correct 8 ms 456 KB Output is partially correct
14 Partially correct 8 ms 344 KB Output is partially correct
15 Partially correct 8 ms 344 KB Output is partially correct
16 Partially correct 8 ms 344 KB Output is partially correct
17 Partially correct 9 ms 344 KB Output is partially correct
18 Partially correct 8 ms 344 KB Output is partially correct
19 Partially correct 9 ms 460 KB Output is partially correct
20 Partially correct 9 ms 344 KB Output is partially correct
21 Partially correct 8 ms 344 KB Output is partially correct
22 Partially correct 8 ms 344 KB Output is partially correct
23 Partially correct 8 ms 344 KB Output is partially correct
24 Partially correct 9 ms 344 KB Output is partially correct
25 Partially correct 8 ms 344 KB Output is partially correct
26 Partially correct 14 ms 344 KB Output is partially correct
27 Partially correct 13 ms 344 KB Output is partially correct
28 Partially correct 8 ms 344 KB Output is partially correct
29 Partially correct 9 ms 344 KB Output is partially correct
30 Partially correct 10 ms 344 KB Output is partially correct
31 Partially correct 8 ms 344 KB Output is partially correct
32 Partially correct 9 ms 344 KB Output is partially correct
33 Partially correct 10 ms 344 KB Output is partially correct
34 Partially correct 8 ms 344 KB Output is partially correct
35 Partially correct 14 ms 344 KB Output is partially correct
36 Partially correct 14 ms 344 KB Output is partially correct
37 Partially correct 10 ms 460 KB Output is partially correct
38 Partially correct 9 ms 344 KB Output is partially correct
39 Partially correct 9 ms 344 KB Output is partially correct
40 Partially correct 8 ms 344 KB Output is partially correct