Submission #1081047

# Submission time Handle Problem Language Result Execution time Memory
1081047 2024-08-29T17:32:19 Z Hectorungo_18 Prisoner Challenge (IOI22_prison) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>

// #include "messy.h"
using namespace std;

mt19937 gnd(time(nullptr));
// #define f first
// #define s second
// #define int long long


vector<vector<int>> devise_strategy(int n){

    int mx = log2(n);
    // mx-=1;
    vector<vector<int>> v(2*mx+1, vector<int> (n+1));
    int la = 2*mx;
    int cnt = 4;
    for(int i = la; i >= 0; i--){
        if(cnt > 2){
            v[i][0]=1;
        }
        else{
            v[i][0]=0;
        }
        cnt--;
        if(cnt == 0) cnt=4;
    }
    v[0][0]=0;

    for(int i = 1; i <= n; i++){
        if(i&(1<<mx)) v[0][i]=2*mx-2;
        else v[0][i]=2*mx-3;
    }
     cnt = 4;
    for(int i = 2*mx-2; i >= -1; i--){
        i+=2;
        if(cnt == 4){
            int cur = (i-1)/2+1;
            for(int j = 1; j <= n; j++){
                if(j&(1<<cur)){
                    if(j&(1<<(cur-1))){
                        if(i >= 3){
                            v[i][j]=i-2;
                        }
                        else{
                            v[i][j]=-1;
                        }
                    }
                    else{
                        if(i >= 3){
                            v[i][j]=i-3;
                        }
                        else{
                            v[i][j]=-2;
                        }
                    }
                }
                else v[i][j]=-2;
            }
        }
        else if(cnt == 3){
            int cur = (i-1)/2+1;
            for(int j = 1; j <= n; j++){
                if(j&(1<<cur) == 0){
                    if(j&(1<<(cur-1))){
                        if(i >= 3){
                            v[i][j]=i-1;
                        }
                        else{
                            v[i][j]=-1;
                        }
                    }
                    else{
                        if(i >= 3){
                            v[i][j]=i-2;
                        }
                        else{
                            v[i][j]=-2;
                        }
                    }
                }
                else v[i][j]=-1;
            }
        }
        else if(cnt == 2){
            int cur = (i-1)/2+1;
            for(int j = 1; j <= n; j++){
                if(j&(1<<cur)){
                    if(j&(1<<(cur-1))){
                        if(i >= 3){
                            v[i][j]=i-2;
                        }
                        else{
                            v[i][j]=-1;
                        }
                    }
                    else{
                        if(i >= 3){
                            v[i][j]=i-3;
                        }
                        else{
                            v[i][j]=-2;
                        }
                    }
                }
                else v[i][j]=-2;
            }
        }
        else{
            int cur = (i-1)/2+1;
            for(int j = 1; j <= n; j++){
                if(j&(1<<cur) == 0){
                    if(j&(1<<(cur-1))){
                        if(i >= 3){
                            v[i][j]=i-1;
                        }
                        else{
                            v[i][j]=-1;
                        }
                    }
                    else{
                        if(i >= 3){
                            v[i][j]=i-2;
                        }
                        else{
                            v[i][j]=-2;
                        }
                    }
                }
                else v[i][j]=-1;
            }
        }
        cnt--;
        if(cnt == 0) cnt = 4;
        i-=2;
    }
    // cout << mx << endl;
    // for(int i = 0; i < 2*mx-1; i++){
    //     cout << i << "   ";
    //     for(int j = 0; j <= n; j++){
    //         cout << v[i][j] << " ";
    //         if(v[i][j] > 0) cout << " ";
    //     }
    //     cout << endl;
    // }

    return v;
}

Compilation message

prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:65:31: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   65 |                 if(j&(1<<cur) == 0){
      |                      ~~~~~~~~~^~~~
prison.cpp:113:31: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
  113 |                 if(j&(1<<cur) == 0){
      |                      ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Strategy failed for N=2, A=2, B=1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Strategy failed for N=2, A=2, B=1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Strategy failed for N=3, A=2, B=1
2 Halted 0 ms 0 KB -