제출 #728435

#제출 시각아이디문제언어결과실행 시간메모리
728435vjudge1죄수들의 도전 (IOI22_prison)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "prison.h" /* author: aykhn 4/21/2023 */ using namespace std; typedef long long ll; #define OPT ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define pii pair<int,int> #define pll pair<ll,ll> #define all(v) v.begin(), v.end() #define mpr make_pair #define pb push_back #define ts to_string #define fi first #define se second #define inf 0x3F3F3F3F #define infll 0x3F3F3F3F3F3F3F3FLL #define bpc __builtin_popcount #define print(v) for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout<<endl; /* notes: divide the bits into consecutive pairs 00 -> 0 = x 01 -> 1 = x 10 -> 2 = x 11 -> 3 = x can be look as ab where a = 2 and b = 1 so when turned on += them on whiteboard: x*10 + group number max group number = lg(MAX)/2 + 1 = lg(5000)/2 + 1 ~~ 12/2 + 1 = 7 max X = 36 (max 1st group = 1 so 17, 36) 25 + 1.5*3 + 10 = 36 points ----------------- new idea: use 3luk say sistemi every bit has 3 form 0, 1, 2 so i can spare 3 integers to note that, such as a%3 = 0 (a+1)%3 = 1 and so on x = 21 or 22 5000 2 1 0 1 0 1 2 1 another one: assign instead of x to x - 1, then when read + 1 to get x, handle 0, 1, 2 by hand */ vector<vector<int>> devise_strategy(int n) { vector<vector<int>> s(23, vector<int> (n + 1, 0)); vector<vector<int>> b(n + 1, vector<int> (8, 0)); for (int i = 1; i <= n; i++) { int pow = 2187; int x = i; for (int j = 7; j >= 0; j--) { b[i][j] = x/pow; x -= b[i][j]*pow; pow/=3; } } s[0][0] = 0; for (int i = 1; i <= n; i++) { s[0][i] = 7 * 3 + b[i][7] - 1; } for (int i = 1; i <= n; i++) { if (b[i][0] == 2) s[1][i] = -2; else if (b[i][0] == 0) s[1][i] = -1; } for (int i = 22; i > 1; i--) { int pos = (i + 1)/3; int bit = (i + 1)%3; s[i][0] = pos%2; for (int j = 1; j <= n; j++) { if (b[j][pos] < bit) { if (pos%2) s[i][j] = -2; else s[i][j] = -1; } else if (b[j][pos] > bit) { if (pos%2) s[i][j] = -1; else s[i][j] = -2; } else { if (pos == 0) continue; if (b[j][pos - 1] == 0 && pos == 1) s[i][j] = -2; else if (b[j][pos - 1] == 2 && pos == 1) s[i][j] = -1; else { s[i][j] = (pos - 1) * 3 + b[j][pos - 1]; if (s[i][j] > 1) s[i][j]--; } } } } /* positions: 6 -> B 5 -> A 4 -> B 3 -> A 2 -> B 1 -> A 0 -> B */ return s; } int main() { int a, b; int n; cin >> n >> a >> b; vector<vector<int>> v = devise_strategy(n); int f = 0; while (true) { cout << f << endl; int x; if (v[f][0] == 0) x = a; else x = b; if (v[f][x] < 0) { cout << v[f][x] << endl; break; } f = v[f][x]; if (!f) break; } }

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccsDEsdd.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc1WTD4e.o:prison.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status