QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#226135#3132. The League of Sequence DesignersAbtahi#WA 39ms3708kbC++172.5kb2023-10-25 16:32:522023-10-25 16:32:52

Judging History

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

  • [2023-10-25 16:32:52]
  • 评测
  • 测评结果:WA
  • 用时:39ms
  • 内存:3708kb
  • [2023-10-25 16:32:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef unordered_map<int,int> umap;
typedef long double ld;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define popcount __builtin_popcount
#define case cout<<"Case "<<__testcase-testcase<<": ";
#define endl '\n'

#define INF 1e18

const int N=1000000;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int testcase=1;
    cin>>testcase;
    int __testcase=testcase;
    while(testcase--){
       ll k,l;
       cin>>k>>l;
       if(l>=2000) cout<<-1<<endl;
       else{
//            if(k<=N){
//                cout<<max(1LL,l)<<endl;
//                for(int i=0;i<max(1LL,l);i++) cout<< -k <<' ';
//                cout<<endl;
//                continue;
//            }
            int ok=0;

            for(ll z=1;z<2000;z++){
                    //cout<<z<<endl;
                ll md=k%z;
                for(ll a=z-md;a<=N;a+=z){
                    if((a+k)%z) continue;
                    ll b=(a+k)/z;
                    if(b+1>N) continue;
                    if(b+1<=a and z>=2){
                        vector<ll> ans;
                        for(int len=0;len<z-2;len++) ans.pb(0);
                        ans.pb(-1);
                        ans.pb(b+1);
                        while(ans.size()<l) ans.pb(-a);

                        cout<<ans.size()<<endl;
                        for(auto i:ans) cout<<i<<' ';
                        cout<<endl;
                        ok=1;
                        break;
                    }

                    else if(b<a and z>=2 and z+2<2000){

                        vector<ll> ans;
                        for(int len=0;len<z-2;len++) ans.pb(0);
                        ans.pb(-1);
                        ans.pb(b+1);
                        ans.pb(-a);
                        while(ans.size()<l-1) ans.pb(-a);
                        ans.pb(a);

                        cout<<ans.size()<<endl;
                        for(auto i:ans) cout<<i<<' ';
                        cout<<endl;
                        ok=1;
                        break;
                    }

                    if(ok) break;

                }
                if(ok) break;
            }

        if(!ok)cout<<-1<<endl;

       }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 6ms
memory: 3648kb

input:

3
8 3
612 7
4 2019

output:

3
-1 10 -10 
7
-1 614 -614 -614 -614 -614 -614 
-1

result:

ok  (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 39ms
memory: 3708kb

input:

5
8 1999
612 1999
1 1999
1000000000 1999
7777777 1999

output:

1999
-1 10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -...

result:

wrong answer  (test case 5)