답안 #774552

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
774552 2023-07-05T19:49:36 Z vjudge1 코알라 (APIO17_koala) C++17
19 / 100
11 ms 1104 KB
#include <bits/stdc++.h>
#define ve vector
#define vi vector<int>
#define vii vector<ii>
//#define ii pair<int,int>
#define fi first
#define se second
#define ll long long
#define INF 1e18+7
#define pb push_back
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
const int MOD = 1e9+7;
const int nax = 2e5+5;
const int kax = 60+5;
void readio(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
#include "koala.h"

int minValue(int n, int w) {
    int s[n], r[n];
    memset(s, 0, sizeof s);
    memset(r, 0, sizeof r);
    s[0] = 1;
    playRound(s, r);
    int ans = 0;
    for (int i = 1; i < n; ++i)
    {
        if(r[i] == 0) ans = i;
    }
    return ans;
}

int maxValue(int n, int w) {
    int s[n], r[n];
    memset(r, 0, sizeof r);
    for (int i = 0; i < n; ++i)
    {
        s[i] = 1;        
    }
    playRound(s, r);
    vi best;
    for (int i = 0; i < n; ++i)
        if(r[i] == 2) best.pb(i);
    memset(r, 0, sizeof r);
    memset(s, 0, sizeof s);
    for(auto x : best) s[x] = 2;
    playRound(s, r);
    best.clear();
    for (int i = 0; i < n; ++i)
        if(r[i] == 3) best.pb(i);
    memset(s, 0, sizeof s);
    memset(r, 0, sizeof r);
    for(auto x : best) s[x] = 4;
    playRound(s, r);
    best.clear();
    for (int i = 0; i < n; ++i)
        if(r[i] == 5) best.pb(i);
    memset(s, 0, sizeof s);
    memset(r, 0, sizeof r);
    for(auto x : best) s[x] = 11;
    playRound(s, r);
    best.clear();
    for (int i = 0; i < n; ++i)
        if(r[i] == 12) best.pb(i);
    return best[0];
}
int vis[nax],n;
int srch(int cnt, vi best){
    int s[n], r[n];
    memset(r, 0, sizeof r);
    memset(s, 0, sizeof s);
    for (auto x : best)
    {
        s[x] = cnt;        
    }
    best.clear();
    playRound(s,r);
    int nw = cnt;
    if(r[0] == cnt+1 && r[1] != cnt+1) return 0;
    if(r[0] != cnt+1 && r[1] == cnt+1) return 1;
    if(r[0] == cnt+1 && r[1] == cnt+1){
        for (int i = 0; i < n; ++i){
            if(r[i] == cnt+1 && !vis[i]) best.pb(i);
            else vis[i] = 1;
        }
        nw = 100/best.size();
    } else {
        for (int i = 0; i < n; ++i){
            if(r[i] != cnt+1 && !vis[i]) best.pb(i);
            else vis[i] = 1;
        }
    }
    return srch(nw,best);
}
int greaterValue(int N, int w) {
    n = N;
    memset(vis, 0, sizeof vis);
    vi best;
    for (int i = 0; i < n; ++i)
    {
        best.pb(i);
    }
    return srch(1,best);
}

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 'void readio()':
koala.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
koala.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 3 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 328 KB Output is correct
2 Correct 10 ms 208 KB Output is correct
3 Correct 10 ms 324 KB Output is correct
4 Correct 10 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1104 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -