Submission #493404

# Submission time Handle Problem Language Result Execution time Memory
493404 2021-12-11T08:23:03 Z irmuun Nice sequence (IZhO18_sequence) C++17
15 / 100
12 ms 680 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define PI 3.14159265359
ll n,m,t,p,h,b,c,d,e,f,i,j,k,r,l,mod=1000000007,mod1=998244353,MAX=1e18,ans;
pair<ll,ll>a[1000001];
string s,u;
ll df[101];
vector<pair<ll,ll> >v;
vector<ll>dv[101];
void dfs(ll x){
    df[x]=1;
    for(ll i=0;i<dv[x].size();i++){
        if(df[dv[x][i]]==0){
            dfs(dv[x][i]);
        }
    }
}
ll fastPow(ll a,ll b){
    ll d=1;
    while(b>0){
        if(b%2==1){
            d=d*a%mod;
        }
        b/=2;
        a=a*a%mod;
    }
    return d;
}
int main(){
    cin>>t;
    while(t--){
        cin>>n>>m;
        if(n==m){
            cout<<n-1<<endl;
            for(i=1;i<=n-1;i++){
                cout<<i<<' ';
            }
            cout<<endl;
            continue;
        }
        if(n%m==0||m%n==0){
            cout<<max(n,m)-1<<endl;
            if(n>m){
                for(i=1;i<max(n,m);i++){
                    cout<<1<<' ';
                }
                cout<<endl;
            }
            else{
                for(i=1;i<max(n,m);i++){
                    cout<<-1<<' ';
                }
                cout<<endl;
            }
            continue;
        }
        if(min(n,m)==2){
            cout<<max(n,m)<<endl;
            if(n>m){
                for(i=1;i<=n/2;i++){
                    cout<<-100000<<' '<<100001<<' ';
                }
                cout<<-100000<<endl;
            }
            else{
                for(i=1;i<=m/2;i++){
                    cout<<100000<<' '<<-100001<<' ';
                }
                cout<<100000<<endl;
            }
        }
    }
}

Compilation message

sequence.cpp: In function 'void dfs(long long int)':
sequence.cpp:16:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(ll i=0;i<dv[x].size();i++){
      |                ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 1 ms 204 KB Ok
4 Correct 1 ms 204 KB Ok
5 Correct 1 ms 204 KB Ok
6 Correct 1 ms 204 KB Ok
7 Correct 0 ms 204 KB Ok
8 Correct 1 ms 204 KB Ok
9 Correct 1 ms 204 KB Ok
10 Correct 0 ms 204 KB Ok
11 Correct 1 ms 204 KB Ok
12 Correct 0 ms 204 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 1 ms 204 KB Ok
4 Correct 0 ms 204 KB Ok
5 Correct 0 ms 204 KB Ok
6 Correct 2 ms 332 KB Ok
7 Correct 9 ms 628 KB Ok
8 Correct 6 ms 460 KB Ok
9 Correct 12 ms 680 KB Ok
10 Correct 6 ms 588 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 0 ms 304 KB Ok
3 Correct 1 ms 204 KB Ok
4 Incorrect 1 ms 204 KB Jury has the better answer : jans = 9, pans = 2
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 1 ms 204 KB Ok
4 Correct 1 ms 204 KB Ok
5 Correct 1 ms 204 KB Ok
6 Correct 1 ms 204 KB Ok
7 Correct 0 ms 204 KB Ok
8 Correct 1 ms 204 KB Ok
9 Correct 1 ms 204 KB Ok
10 Correct 0 ms 204 KB Ok
11 Correct 1 ms 204 KB Ok
12 Correct 0 ms 204 KB Ok
13 Correct 1 ms 204 KB Ok
14 Correct 0 ms 304 KB Ok
15 Correct 1 ms 204 KB Ok
16 Incorrect 1 ms 204 KB Jury has the better answer : jans = 9, pans = 2
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 1 ms 204 KB Ok
4 Correct 1 ms 204 KB Ok
5 Correct 1 ms 204 KB Ok
6 Correct 1 ms 204 KB Ok
7 Correct 0 ms 204 KB Ok
8 Correct 1 ms 204 KB Ok
9 Correct 1 ms 204 KB Ok
10 Correct 0 ms 204 KB Ok
11 Correct 1 ms 204 KB Ok
12 Correct 0 ms 204 KB Ok
13 Correct 1 ms 204 KB Ok
14 Correct 1 ms 204 KB Ok
15 Correct 1 ms 204 KB Ok
16 Correct 0 ms 204 KB Ok
17 Correct 0 ms 204 KB Ok
18 Correct 2 ms 332 KB Ok
19 Correct 9 ms 628 KB Ok
20 Correct 6 ms 460 KB Ok
21 Correct 12 ms 680 KB Ok
22 Correct 6 ms 588 KB Ok
23 Correct 1 ms 204 KB Ok
24 Correct 0 ms 304 KB Ok
25 Correct 1 ms 204 KB Ok
26 Incorrect 1 ms 204 KB Jury has the better answer : jans = 9, pans = 2
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 1 ms 204 KB Ok
4 Correct 1 ms 204 KB Ok
5 Correct 1 ms 204 KB Ok
6 Correct 1 ms 204 KB Ok
7 Correct 0 ms 204 KB Ok
8 Correct 1 ms 204 KB Ok
9 Correct 1 ms 204 KB Ok
10 Correct 0 ms 204 KB Ok
11 Correct 1 ms 204 KB Ok
12 Correct 0 ms 204 KB Ok
13 Correct 1 ms 204 KB Ok
14 Correct 1 ms 204 KB Ok
15 Correct 1 ms 204 KB Ok
16 Correct 0 ms 204 KB Ok
17 Correct 0 ms 204 KB Ok
18 Correct 2 ms 332 KB Ok
19 Correct 9 ms 628 KB Ok
20 Correct 6 ms 460 KB Ok
21 Correct 12 ms 680 KB Ok
22 Correct 6 ms 588 KB Ok
23 Correct 1 ms 204 KB Ok
24 Correct 0 ms 304 KB Ok
25 Correct 1 ms 204 KB Ok
26 Incorrect 1 ms 204 KB Jury has the better answer : jans = 9, pans = 2
27 Halted 0 ms 0 KB -