QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#135201#5742. Garbage Disposaltselmegkh#WA 1ms3468kbC++201.5kb2023-08-05 12:47:042023-08-05 12:47:07

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-05 12:47:07]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3468kb
  • [2023-08-05 12:47:04]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
using namespace std;

const int N = 2e5 + 5, inf = 1e9;
#define pb push_back
#define mp make_pair
#define ll long long
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define sz(x) (int)x.size()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

void solve(){
    ll l, r;
    cin >> l >> r;
    if(l == r){
        cout << -1 << '\n';
        return;
    }
    if(r - l == 1){
        cout << r << ' ' << l << '\n';
        return;
    }
    if(r - l == 2){
        if(l % 2 == 0){
            cout << -1 << '\n';
            return;
        }
        else{
            cout << r << ' ' << l << ' ' << l + 1 << '\n';
            return;
        }
    }
    for(ll i = l + 1; i <= r - 2; i++){
        if(__gcd(i, l) == 1 && __gcd(r, i + 1) == 1){
            for(ll j = l; j < i; j++){
                cout << j + 1 << ' ';
            }
            cout << l << ' ';
            for(ll j = i + 1; j < r; j++){
                cout << j + 1 << ' ';
            }
            cout << i + 1;
            cout << '\n';
            return;
        }
    }
    cout << -1 << '\n';
    return;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t = 1;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3460kb

input:

3
1 5
10 13
100 100

output:

2 1 4 5 3
11 10 13 12
-1

result:

ok 3 cases (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3468kb

input:

2
1 1
10 12

output:

-1
-1

result:

wrong answer Jury found answer but participant didn't (test case 1)