Submission #774153

#TimeUsernameProblemLanguageResultExecution timeMemory
774153jasminPrisoner Challenge (IOI22_prison)C++17
0 / 100
1 ms212 KiB
#include "prison.h"
#include<bits/stdc++.h>
using namespace std;

const int L=13;

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

    vector<vector<int> > ans(L*3+1, vector<int> (n+1, -1));

    for(int x=0; x<=L*3; x++){

        if(x%3==0){//look at A
            ans[x][0]=1;

            int l=L-(x/3);
            for(int a=1; a<=n; a++){

                if(a&(1<<l)==0){
                    ans[x][a]=x+1;
                }
                else{
                    ans[x][a]=x+2;
                }

            }

        }
        else{ //look at B
            ans[x][0]=2;

            int bita=x%3-1;
            int l=L-(x/3);
            for(int b=1; b<=n; b++){

                int bitb = b&(1<<l);

                if(bita<bitb){
                    ans[x][b]=-1;
                }
                else if(bita>bitb){
                    ans[x][b]=-2;
                }
                else{
                    ans[x][b] = (x/3 +1)*3;
                }

            }

        }

    }
    
    return ans;
}

Compilation message (stderr)

prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:19:28: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   19 |                 if(a&(1<<l)==0){
      |                      ~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...