Submission #1026492

#TimeUsernameProblemLanguageResultExecution timeMemory
1026492MardonbekhazratovPrisoner Challenge (IOI22_prison)C++17
0 / 100
0 ms348 KiB
#include "prison.h" #include <vector> #include <bits/stdc++.h> using namespace std; int n; vector<vector<int>>ans; void solve(int l,int r,int c,int id){ ans[id][0]=c; c^=1; for(int i=1;i<l;i++){ ans[id][i]=c^(-2); } for(int i=r+1;i<=n;i++){ ans[id][i]=c^(-1); } ans[id][l]=c^(-2); ans[id][r]=c^(-1); if(l>=r-1) return; l++,r--; int mid=(l+r)/2; ans.push_back(vector<int>(n+1)); for(int i=l;i<=mid;i++) ans[id][i]=ans.size()-1; solve(l,mid,c,ans.size()-1); if(mid>=r) return; // ans.push_back(vector<int>(n+1)); // for(int i=mid+1;i<=r;i++) ans[id][i]=ans.size()-1; // solve(mid+1,r,c,ans.size()-1); } std::vector<std::vector<int>> devise_strategy(int N) { n=N; ans.assign(1,vector<int>(N+1)); solve(1,N,0,0); int mid=(3+n)/2; for(int i=mid;i<n;i++){ ans[0][i]=ans.size(); } vector<vector<int>>new_ans; for(int i=1;i<ans.size();i++){ vector<int>a=ans[i]; reverse(a.begin(),a.end()); vector<int>b={ans[i][0]}; a.pop_back(); for(int x:a){ if(x==-1) b.push_back(-2); else if(x==-2) b.push_back(-1); else b.push_back(x+ans.size()-1); } new_ans.push_back(b); } for(auto x:new_ans) ans.emplace_back(x); cout<<ans.size()<<'\n'; for(auto x:ans){ for(auto y:x) cout<<y<<' '; cout<<'\n'; } return ans; }

Compilation message (stderr)

prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:43:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for(int i=1;i<ans.size();i++){
      |                 ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...