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>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define FOR(T) for(int i = 1;i <= T;i++) solve();
#define READ(a) for(int i = 0;i < a.size();i++) cin >> a[i];
#define NTL ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18;
const int sz = 1e6 + 5;
const int mod = 1e9 + 7;
int cnt(int x , int y , int n)
{
int cl = abs(x - y);
int y2;
if(y >= x)
{
y2 = x + ((2*n) - y);
}
else
{
y2 = y + ((2*n) - x);
}
return (min(cl,y2));
}
void solve(){
int n , m , q;
cin >> n >> m >> q;
int d;
cin >> d;
while(q--)
{
int x , y;
cin >> x >> y;
cout << min(cnt(x , y , n) , 1 + cnt(d + n , y , n)) << endl;
}
}
signed main(){
NTL;
int T = 1;
//cin >> T;
FOR(T);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |