Submission #658499

#TimeUsernameProblemLanguageResultExecution timeMemory
658499YassineBenYounesPrisoner Challenge (IOI22_prison)C++17
48.50 / 100
32 ms1364 KiB
/* ID: Yassine BenYounes TASK: hoofball LANG: C++ */ #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> /*#define pbds \ tree<pair<int, int>, null_type, less<pair<int, int> >, \ rb_tree_tag, tree_order_statistics_node_update> using namespace __gnu_pbds;*/ typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef double db; ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD) ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM) ll modd(ll x, ll n){while(x < 0){x += n;}return (x % n);} // modulo for negative numbers int dx[4] = {1, -1, 0, 0 }; int dy[4] = {0, 0, 1, -1}; #define endl "\n" #define ss second #define ff first #define all(x) (x).begin() , (x).end() #define pb push_back #define vi vector<int> #define vii vector<pair<int,int>> #define vl vector<ll> #define vll vector<pair<ll,ll>> #define pii pair<int,int> #define pll pair<ll,ll> #define pdd pair<double,double> #define vdd vector<pdd> #define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; void init(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // ONLINE_JUDGE } const int mx = 1e5 + 9; const ll mod = 1e9+7; const int inf = 1e9; int find_bit(int target, int k){ vi v; while(target > 0){ int x = target; target = target / 3; v.pb(x % 3); } reverse(all(v)); while(v.size() < 8){ v.insert(v.begin(), 0); } return v[k]; } vi identify(int n){ if(n >= 25){ return {n - 24, 0, 1}; } int bit = (n - 1) % 3; int tartib = (n-1) / 3; return {tartib, bit, 0}; } int transform(int tartib, int bit, int player){ if(player == 1){ return 24 + tartib; } int x = tartib * 3 + bit + 1; return x; } int n; std::vector<std::vector<int>> devise_strategy(int N){ vector<vi> v(32, vi(N+1)); n = N; v[0][0] = 0; for(int j = 1; j <= N;j++){ int tartib = 0; int bit = find_bit(j, tartib); int player = 0; int number = transform(tartib, bit, player); v[0][j] = number; } for(int i = 1; i <= 31;i++){ vi vec = identify(i); int tartib = vec[0]; int bit = vec[1]; int player = vec[2]; if(player == 0){ v[i][0] = 1; for(int j = 1;j <= N;j++){ int x = find_bit(j, tartib); if(x < bit){ v[i][j] = -2; } else if(bit < x){ v[i][j] = -1; } else{ int number = transform(tartib+1, x, 1); if(tartib == 7)continue; //cout << tartib << " " << bit << " " << player << " : " << number << endl; v[i][j] = number; } } } else{ v[i][0] = 0; //cout << tartib+1 << endl; for(int j = 1;j <= N;j++){ int x = find_bit(j, tartib); int number = transform(tartib, x, 0); v[i][j] = number; } } } return v; } /* int main(){ init(); speed; vector<vi> v = devise_strategy(3); for(int i = 0; i <= 31;i++){ for(int j = 0;j <= n;j++){ cout << v[i][j] << " "; } cout << endl; } //tartib, bit, player // cout << transform(1, 0, 1) << endl; vi vec = identify(31); int tartib = vec[0]; int bit = vec[1]; int player = vec[2]; for(int x : vec){ cout << x << endl; } //cout << find_bit(1, 7) << endl; }*/

Compilation message (stderr)

prison.cpp: In function 'void init()':
prison.cpp:41:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 | freopen("input.txt", "r", stdin);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
prison.cpp:43:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 | freopen("output.txt", "w", stdout);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...