Task: | Hypyt |
Sender: | Laakeri |
Submission time: | 2025-10-18 01:44:55 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 30 |
#2 | ACCEPTED | 70 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.00 s | 1, 2 | details |
#2 | ACCEPTED | 0.01 s | 1, 2 | details |
#3 | ACCEPTED | 0.10 s | 2 | details |
#4 | ACCEPTED | 0.26 s | 2 | details |
#5 | ACCEPTED | 0.37 s | 2 | details |
Code
#include <bits/stdc++.h> #define F first #define S second using namespace std; typedef long long ll; typedef long double ld; pair<int,int> dif(pair<int,int> from, pair<int,int> to){ return {to.F-from.F, to.S-from.S}; } vector<pair<int,int>> solve(int n, int m){ assert(n>=m); int a=1; int b=n; pair<int,int> cp={1,1}; vector<pair<int,int>> ans; while (a<b){ for (int i=0;i<m;i++){ pair<int,int> t1={a,i+1}; pair<int,int> t2={b,m-i}; if (t1 != cp){ ans.push_back(dif(cp, t1)); } ans.push_back(dif(t1, t2)); cp=t2; } a++; b--; } if (b<a){ return ans; } for (int i=0;i<m;i++){ pair<int,int> t1={a,i+1}; pair<int,int> t2={a,m-i}; if (t1.S>t2.S){ return ans; } if (t1!=cp){ ans.push_back(dif(cp, t1)); } if (t1==t2){ return ans; } ans.push_back(dif(t1,t2)); cp=t2; } assert(0); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int tcs; cin>>tcs; for (int tc=0;tc<tcs;tc++){ int n,m; cin>>n>>m; int iv=0; if (n<m){ swap(n,m); iv=1; } auto sol=solve(n,m); assert((int)sol.size()==n*m-1); for (auto t : sol){ if (iv){ cout<<t.S<<" "<<t.F<<endl; } else { cout<<t.F<<" "<<t.S<<endl; } } } }
Test details
Test 1
Group: 1, 2
Verdict: ACCEPTED
input |
---|
25 1 1 1 2 1 3 1 4 ... |
correct output |
---|
0 1 0 2 0 -1 0 3 0 -2 ... |
user output |
---|
0 1 0 2 0 -1 0 3 0 -2 ... |
Test 2
Group: 1, 2
Verdict: ACCEPTED
input |
---|
100 5 5 5 5 5 5 5 5 ... |
correct output |
---|
4 4 -4 -3 4 2 -4 -1 4 0 ... |
user output |
---|
4 4 -4 -3 4 2 -4 -1 4 0 ... |
Test 3
Group: 2
Verdict: ACCEPTED
input |
---|
100 1 25 20 40 5 34 50 34 ... |
correct output |
---|
0 24 0 -23 0 22 0 -21 0 20 ... |
user output |
---|
0 24 0 -23 0 22 0 -21 0 20 ... |
Test 4
Group: 2
Verdict: ACCEPTED
input |
---|
100 46 47 41 39 46 36 46 30 ... |
correct output |
---|
45 46 -45 -45 45 44 -45 -43 45 42 ... |
user output |
---|
45 46 -44 -46 43 46 -42 -46 41 46 ... |
Test 5
Group: 2
Verdict: ACCEPTED
input |
---|
100 50 50 50 50 50 50 50 50 ... |
correct output |
---|
49 49 -49 -48 49 47 -49 -46 49 45 ... |
user output |
---|
49 49 -49 -48 49 47 -49 -46 49 45 ... |