이 제출은 이전 버전의 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);
}
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 = 4;
const int start = 6;
int get(int x, int i) {
while (i--) x /= himq;
return x % himq;
}
VVI ans;
void prisoner(int id, int x) {
auto[type, ind, VAL] = decode[id];
ans[id][0] = type;
if (type) {
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[{0, ind, 0}];
}
} else {
int val = get(x, ind);
ans[id][x] = encode[{1, ind, val}];
}
}
VVI devise_strategy(int n) {
add({0, start, 0});
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 << ans.size() << endl;*/
return ans;
int A, B;
cin >> A >> B;
int cur = 0;
rep(i, 20) {
cout << "ID: " << cur << endl;
auto[type, ind, val] = decode[cur];
cout << "grac e " << type << " " << 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... |