Submission #493373

# Submission time Handle Problem Language Result Execution time Memory
493373 2021-12-11T07:40:46 Z irmuun Gift (IZhO18_nicegift) C++17
0 / 100
1198 ms 44000 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,c,d,e,f,i,j,k,r,l,mod=1000000007,mod1=998244353,MAX=1e18,ans;
pair<ll,ll>a[1000001],b[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>>n>>k;
    ll mn=MAX;
    ll mx=0;
    for(i=1;i<=n;i++){
        cin>>a[i].ff;
        //b[i]=a[i].ff;
        a[i].ss=i;
        mn=min(mn,a[i].ff);
        mx=max(mx,a[i].ff);
    }
    if(mn==mx){
        cout<<(n+k-1)/k<<endl;
        c=0;
        for(i=1;i<=n-k;i+=k){
            c++;
            cout<<mn<<' ';
            for(j=i;j<i+k;j++){
                cout<<j<<' ';
            }
            cout<<endl;
        }
        if(n%k>0){
            cout<<mn<<' ';
            for(i=n-k+1;i<=n;i++){
                cout<<i<<' ';
            }
            cout<<endl;
        }
        return 0;
    }
    if(k==2){
        sort(a+1,a+n+1);
        r=0;
        for(i=2;i<=n;i++){
            if(a[i].ff==a[i-1].ff){
                r=i;
                break;
            }
        }
        if(r==0){
            cout<<-1;
            return 0;
        }
        cout<<n-1<<endl;
        for(i=1;i<=n;i++){
            if(i==r-1||i==r){
                continue;
            }
            cout<<a[i].ff<<' '<<a[i].ss<<' '<<a[r].ss<<endl;
        }
        cout<<a[r].ff<<' '<<a[r].ss<<' '<<a[r-1].ss<<endl;
        return 0;
    }
}

Compilation message

nicegift.cpp: In function 'void dfs(long long int)':
nicegift.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 Incorrect 0 ms 204 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1198 ms 44000 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -