#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 |
1 |
Correct |
30 ms |
336 KB |
Output is correct |
2 |
Correct |
30 ms |
516 KB |
Output is correct |
3 |
Correct |
31 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
31 ms |
760 KB |
Output is correct |
6 |
Correct |
34 ms |
840 KB |
Output is correct |
7 |
Correct |
31 ms |
848 KB |
Output is correct |
8 |
Correct |
32 ms |
848 KB |
Output is correct |
9 |
Correct |
32 ms |
848 KB |
Output is correct |
10 |
Correct |
32 ms |
980 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
2 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
2 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
848 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Incorrect |
31 ms |
848 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
336 KB |
Output is correct |
2 |
Correct |
30 ms |
516 KB |
Output is correct |
3 |
Correct |
31 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
31 ms |
760 KB |
Output is correct |
6 |
Correct |
34 ms |
840 KB |
Output is correct |
7 |
Correct |
31 ms |
848 KB |
Output is correct |
8 |
Correct |
32 ms |
848 KB |
Output is correct |
9 |
Correct |
32 ms |
848 KB |
Output is correct |
10 |
Correct |
32 ms |
980 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Incorrect |
2 ms |
336 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |