QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#505218 | #5742. Garbage Disposal | chimera | WA | 0ms | 3624kb | C++14 | 890b | 2024-08-04 22:34:31 | 2024-08-04 22:34:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll x, ll y) {
if(y == 0) return x;
return gcd(y, x % y);
}
int main() {
ll T; cin >> T;
for(ll t = 0; t < T; t++) {
ll L, R; cin >> L >> R;
if(L == R) {
cout << "-1\n"; continue;
}
// if even: always possible.
if((R - L + 1)%2 == 0) {
goodcase:
for(ll i = L; i <= R; i += 2) {
cout << i+1 << " " << i << " ";
}
cout << "\n";
continue;
}
// evens > odds: always impossible.
// o.w. possible. (3-cycle involving odds, and then evens.)
if(!(L%2)) {
cout << -1 << "\n"; continue;
}
cout << L+2 << " " << L << " " << L+1 << " "; L += 3;
goto goodcase;
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
3 1 5 10 13 100 100
output:
3 1 2 5 4 11 10 13 12 -1
result:
ok 3 cases (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3580kb
input:
2 1 1 10 12
output:
-1 -1
result:
wrong answer Jury found answer but participant didn't (test case 1)