# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
372774 | Killer2501 | 케이크 (JOI13_cake) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pb push_back
#define vii vector<int>
#define task "ABC"
#define pll pair<ll, ll>
#define pii pair< pll, ll >
#define fi first
#define se second
#include 'grader.h'
using namespace std;
using ll = int;
using ull = unsigned long long;
const int N = 3e5+5;
const ll mod = 1e9+7;
const ll base1 = 1313;
const ll base2 = 3113;
string s;
ll pw(ll k, ll n)
{
ll total = 1;
for(; n; n >>= 1)
{
if(n & 1)total = total * k % mod;
k = k * k % mod;
}
return total;
}
void cal(ll xl, ll yl, ll xr, ll yr, ll u, ll v, ll val)
{
ll x = (u == 1 ? xl : xr);
ll y = (v == 1 ? yr : yl);
ll cur = Measure(x, y);
if(cur == val)
{
Pinpoint(x, y);
exit(0);
}
if(cur < val)
{
if(u == 1)cal(xl+1, yl, xr, yr, u, v, val);
else cal(xl, yl, xr-1, yr, u, v, val);
}
else
{
if(v == 1)cal(xl, yl, xr, yr-1, u, v, val);
else cal(xl, yl+1, xr, yr, u, v, val);
}
}
void Rescue ( int R, int C, int RS, int CS, int X)
{
cal(1, 1, RS, CS, 1, 1, X);
cal(RS, 1, R, CS, 0, 1, X);
cal(1, CS, RS, C, 1, 0, X);
cal(RS, CS, R, C, 0, 0, X);
}