Submission #1013014

# Submission time Handle Problem Language Result Execution time Memory
1013014 2024-07-03T05:29:29 Z Almonther Sticks (POI11_pat) C++
100 / 100
154 ms 23636 KB
#include <bits/stdc++.h>
 
#define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define co cout<<
// #pragma GCC optimize("O3,Ofast,unroll-loops")
// #pragma GCC target("avx2,sse3,sse4,avx")
using namespace std;
//stuff
ll n;
pair<ll,ll>arr[3000001];
ll cnt=0;
void solve(){
    cin>>n;
    for(int i=1;i<=n;i++){
        ll x;
        cin>>x;
        for(int j=0;j<x;j++){
            ll y;
            cin>>y;
            arr[cnt]={y,i};
            cnt++;
        }
    }
    sort(arr,arr+cnt);
    for(int i=0;i<cnt;i++) swap(arr[i].first,arr[i].second);
    // for(int i=0;i<cnt;i++) co arr[i].second<<' ';
    // co '\n';
    ll i,j,k;
    j=k=0;
    while(arr[k].first==arr[j].first&&j<cnt) j++;
    i=j;
    while((arr[j].first==arr[i].first||arr[i].first==arr[k].first)&&i<cnt) i++;
    for(int l=i-1;i>=0;i--){
        if(arr[l].first==arr[j].first){
            j=l;
            break;
        }
    }
    for(int l=j-1;i>=0;i--){
        if(arr[l].first==arr[k].first){
            k=l;
            break;
        }
    }
    if(i>=cnt||j>=cnt||k>=cnt){
        co "NIE";
        return;
    }
    while(1){
        // co i<<' '<<j<<' '<<k<<'\n'<<arr[i].first<<' '<<arr[j].first<<' '<<arr[k].first<<'\n';
        ll a,b,c;
        a=arr[i].second;
        b=arr[j].second;
        c=arr[k].second;
        // co a<<' '<<b<<' '<<c<<"\nend\n";
        if(a+b>c&&a+c>b&&c+b>a){
            co arr[i].first<<' '<<a<<' '<<arr[j].first<<' '<<b<<' '<<arr[k].first<<' '<<c;
            return;
        }
        if(i+1>=cnt){
            co "NIE";
            return;
        }
        if(arr[i].first==arr[i+1].first){
            i++;
        }
        else if(arr[i+1].first==arr[j].first){
            j=i;
            i++;
        }
        else{
            k=j;
            j=i;
            i++;
        }
    }
}
 
int main()
{
    suiii
    int tt=1;
    // cin>>tt;
    while(tt--){
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Oczekiwano NIE
2 Correct 4 ms 2776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Oczekiwano NIE
2 Correct 5 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Oczekiwano NIE
2 Correct 13 ms 2624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2652 KB Oczekiwano NIE
2 Correct 19 ms 3932 KB Output is correct
3 Correct 13 ms 3416 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3172 KB Oczekiwano NIE
2 Correct 33 ms 6748 KB Output is correct
3 Correct 22 ms 6032 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 69 ms 12008 KB Output is correct
2 Correct 43 ms 7796 KB Output is correct
3 Correct 32 ms 5980 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 73 ms 12108 KB Output is correct
2 Correct 46 ms 8784 KB Output is correct
3 Correct 41 ms 7508 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 154 ms 23636 KB Output is correct
2 Correct 53 ms 9808 KB Output is correct
3 Correct 59 ms 10424 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 143 ms 23548 KB Output is correct
2 Correct 62 ms 11344 KB Output is correct
3 Correct 70 ms 12348 KB Oczekiwano NIE