제출 #1062432

#제출 시각아이디문제언어결과실행 시간메모리
1062432mindiyak죄수들의 도전 (IOI22_prison)C++17
65 / 100
8 ms1632 KiB
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops") #include <bits/stdc++.h> #include <string> #include <iostream> #include <cmath> #include <numeric> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pi; typedef pair<int, int> pl; typedef pair<ld, ld> pd; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<vi> vvi; typedef vector<ld> vd; typedef vector<ll> vl; typedef vector<pi> vpi; typedef vector<pl> vpl; #define FOR(i, a, b) for (int i = a; i < (b); i++) #define F0R(i, a) for (int i = 0; i < (a); i++) #define FORd(i, a, b) for (int i = (b)-1; i >= a; i--) #define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--) #define trav(a, x) for (auto &a : x) #define uid(a, b) uniform_int_distribution<int>(a, b)(rng) #define len(x) (int)(x).size() #define mp make_pair #define pb push_back #define F first #define nl endl #define S second #define lb lower_bound #define ub upper_bound #define aint(x) x.begin(), x.end() #define raint(x) x.rbegin(), x.rend() #define ins insert const int MOD = 1000000007; vi convert(int n){ vi arr(8,0); int pos = 7; while(n>0){ arr[pos] = n%3; n/=3; pos --; } return arr; } vvi devise_strategy(int N) { vvi base3(5005,vi (8,0)); for(int i=1;i<N+1;i++)base3[i] = convert(i); vvi arr (25,vi(N+1,0)); for(int j = 1;j <= N;j++){ arr[0][j] = base3[j][0] + 1; } for(int i=1;i<25;i++){ // if((4<=i && i<=6) || (10<=i && i<=12) || (16<=i && i<=18))arr[i][0] = 0; // else arr[i][0] = 1; int level = 0; if(i<=3)level = 0; else if(i<=6)level = 1; else if(i<=9)level = 2; else if(i<=12)level = 3; else if(i<=15)level = 4; else if(i<=18)level = 5; else if(i<=21)level = 6; else if(i<=24)level = 7; arr[i][0] = (level + 1) % 2; for(int j = 1;j <= N;j++){ int num = base3[j][level]; int val = (i-1) % 3; if(val==num)arr[i][j] = base3[j][level+1] + (level+1)*3 + 1; if(val<num)arr[i][j] = (arr[i][0] == 1) ? -1 : -2; if(val>num)arr[i][j] = (arr[i][0] == 1) ? -2 : -1; if(val==num && level == 7)arr[i][j] = 0; // if(level == 6 && val==num) { // if (base3[j][level+1] == 1) arr[i][j] = 22; // else if (base3[j][level+1] == 0) arr[i][j] = (arr[i][0] == 1) ? -1 : -2; // else arr[i][j] = (arr[i][0] == 1) ? -2 : -1; // } } } // arr[22][0] = 0; // for(int j = 1;j <= N;j++){ // arr[22][j] = (base3[j][7] == 0) ? -1 : -2; // } // FILE *log_file = fopen("log1.txt","w"); // int counter = 0; // for(auto a: arr){ // fprintf(log_file, "%d -> ", counter); // for(auto b: a){ // fprintf(log_file, "%d ", b); // } // fprintf(log_file, "\n"); // counter ++; // } // fflush(log_file); // FILE *log_file2 = fopen("log2.txt","w"); // counter = 0; // for(auto a: base3){ // fprintf(log_file2, "%d -> ", counter); // for(auto b: a){ // fprintf(log_file2, "%d ", b); // } // fprintf(log_file2, "\n"); // counter ++; // } // fflush(log_file2); return arr; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...