Submission #742926

#TimeUsernameProblemLanguageResultExecution timeMemory
742926merlinPrisoner Challenge (IOI22_prison)C++17
56 / 100
17 ms1248 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
//https://ioi.contest.codeforces.com/group/32KGsXgiKA/contest/103877/problem/B

void setIO(string name="") {
	cin.tie(0)->sync_with_stdio(0);
	if (!name.empty()) {
		freopen((name+".in").c_str(), "r", stdin);
		freopen((name+".out").c_str(), "w", stdout);
	}
}

vector<vector<int>> devise_strategy(int n){
    //const int maxBit = 13;
    int maxBit = 1;
    while(1<<maxBit <= n) maxBit++;
    maxBit--;
    vector<vector<int>> ans(2*maxBit+3,vector<int>(n+1));
    for(int i = 1;i<2*maxBit+3;i++){
        int cur_bit = (i-1)/2;
        for(int j = 1;j<=n;j++){
            int set_b = j & (1<<cur_bit);
            if((set_b != 0 && i%2 == 0) || (set_b == 0 && i%2)){ //ak nechcem odpovedat
                ans[i][j] = 2*(cur_bit - 1)+1;
                if(j & 1<<(cur_bit - 1)) ans[i][j]++;
            }else{ //idem odpovedat
                if(1 - (maxBit - cur_bit)%2){ //posledne som meral B
                    if(i%2 && (j & 1<<cur_bit)){
                        ans[i][j] = -1;
                    }else{
                        ans[i][j] = -2;
                    }
                }else{ //posledne som meral A
                    if(i%2 && (j & 1<<cur_bit)){
                        ans[i][j] = -2;
                    }else{
                        ans[i][j] = -1;
                    }
                }
            }
        }
        ans[i][0] = 1 - (maxBit - cur_bit)%2;
    }
    for(int j = 1;j<=n;j++){
        ans[0][j] = 2*maxBit + 1;
        if(j & (1<<maxBit)) ans[0][j] ++;
    }
    ans[0][0] = 0;
    ans[0][1] = -1;
    return ans;
}

Compilation message (stderr)

prison.cpp: In function 'void setIO(std::string)':
prison.cpp:11:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   freopen((name+".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prison.cpp:12:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   freopen((name+".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...