이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "prison.h"
struct QUERY {
/*int type;*/
int ind;
int val;
/*
* type = 0
* grel a-i arjeq@
* type = 1
* hamematel b-i arjeq@ a-i het
*/
};
bool operator<(const QUERY& a, const QUERY& b) {
/*return make_tuple(a.type, a.ind, a.val) < make_tuple(b.type, b.ind, b.val);*/
return make_tuple(a.ind, a.val) < make_tuple(b.ind, b.val);
}
int b = 0;
map<int, QUERY> decode;
map<QUERY, int> encode;
void add(QUERY x) {
if (encode.count(x)) return;
decode[b] = x;
encode[x] = b;
b++;
}
const int himq = 3;
int start;
void getstart(int n) {
start = 0;
while (n) {
n /= himq;
start++;
}
start--;
}
int get(int x, int i) {
while (i--) x /= himq;
return x % himq;
}
VVI ans;
void prisoner(int id, int x) {
auto[ind, VAL] = decode[id];
bool which = ind%2;
ans[id][0] = which;
if (which) {
int valA = VAL;
int valB = get(x, ind);
if (valA < valB) {
ans[id][x] = -1;
} else if (valA > valB) {
ans[id][x] = -2;
} else {
ind--;
if (ind < 0) return;
ans[id][x] = encode[{ind, get(x, ind)}];
}
} else {
int valA = get(x, ind);
int valB = VAL;
if (valA < valB) {
ans[id][x] = -1;
} else if (valA > valB) {
ans[id][x] = -2;
} else {
ind--;
if (ind < 0) return;
ans[id][x] = encode[{ind, get(x, ind)}];
}
}
}
VVI devise_strategy(int n) {
getstart(n);
add({start+1, 0});
replr(ind, 0, start) {
rep(v, himq) {
add({ind, v});
}
}
/*replr(ind, 0, start) {*/
/* add({0, ind, 0});*/
/* rep(v, himq) {*/
/* add({1, ind, v});*/
/* }*/
/*}*/
ans = VVI(b, VI(n+1));
rep(i, b) rep(j, n+1) prisoner(i, j);
/*cout << start << endl;*/
return ans;
int A, B;
cin >> A >> B;
int cur = 0;
rep(i, 20) {
cout << "ID: " << cur << endl;
auto[ind, val] = decode[cur];
cout << "grac e " << ind << " " << val << endl;
int harc = (ans[cur][0] ? B : A);
cout << "Harcrec qash@, stacav " << harc << endl;
if (ans[cur][harc] == -1) {
cout << "PATASXAN@ A" << endl;
break;
}
if (ans[cur][harc] == -2) {
cout << "PATASXAN@ B" << endl;
break;
}
cur = ans[cur][harc];
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |