Zaku @ 2024-09-16 19:29:25
思路是先转换成
结果就过了子任务2/kk
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
vector<pair<int, int> > ans;
int a, b, c, d;
cin >> a >> b >> c >> d;
int x = a * b, y = c * d;
if (x < y || x == 2){
cout << -1 << '\n';
return ;
}
int m = 1, op = 0;
ans.push_back({1, a});
while (1){
if (x / 2 < y){
x = y;
ans.push_back({2 - op, x});
op = !op;
if (op){
if (x == c){
m ++;
break;
}
ans.push_back({2 - op, d});
}
else{
if (x == d){
m ++;
break;
}
ans.push_back({2 - op, c});
}
m += 2;
break;
} else{
int k = x / 2 + 1;
x -= k;
ans.push_back({2 - op, k});
op = !op;
m ++;
}
}
cout << m << '\n';
for (auto i : ans)
cout << i.first << ' ' << i.second << '\n';
return ;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T = 1;
cin >> T;
while (T -- ){
solve();
}
return 0;
}
by litangzheng @ 2024-09-16 19:42:46
我跟你一样,写了一堆又臭又长也只得了31分,连样例2都没过。第一个测试点WA,第二个AC,第三个TLE。 @Zaku
by Zaku @ 2024-09-16 21:21:12
@LTZ_DSG 我调出来了 这题实现有点绕但是思路没啥大问题