제출 #96054

#제출 시각아이디문제언어결과실행 시간메모리
96054MohamedAhmed0새로운 문제 (POI11_pat)C++14
100 / 100
448 ms4600 KiB
#include <bits/stdc++.h>
 
using namespace std;
 
const int MAXK = 55 ;
const int MAXN = 1e6+10 ;
int arr[MAXK][MAXN] , sz[MAXK];
int k ;
 
bool is_triangle(long long x , long long y , long long z)
{
    return (x < y+z && y < x + z && z < x+y) ;
}
 
int main()
{
    int n ;
    cin>>n ;
    for(int i = 0 ; i < n ; ++i)
    {
        cin>>sz[i] ;
        for(int j = 0 ; j < sz[i] ; ++j)
            cin>>arr[i][j] ;
        sort(arr[i] , arr[i] + sz[i]) ;
    }
    for(int i = 0 ; i < n ; ++i)
    {
        for(int i2 = 0 ; i2 < sz[i] ; ++i2)
        {
            long long a = arr[i][i2] ;
            long long l = -1e12 , m = 1e12 , cl = -1 , cm = -1;
            for(int j = 0 ; j < n ; ++j)
            {
                if(i == j)
                    continue;
                int high = lower_bound(arr[j] , arr[j] + sz[j] , a) - arr[j] ;
                int low = high-1 ;
                if(high != sz[j])
                {
                    if(is_triangle(a*1ll , l*1ll ,  arr[j][high] * 1ll) && cl != -1)
                        return cout<<i+1<<" "<<a<<" "<<cl+1<<" "<<l<<" "<<j+1<<" "<<arr[j][high]<<"\n" , 0 ;
                }
                if(arr[j][high] == a)
                    low = high ;
                if(low >= 0)
                {
                    if(is_triangle(a * 1ll , m  * 1ll , arr[j][low] * 1ll) && cm != -1)
                        return cout<<i+1<<" "<<a<<" "<<cm+1<<" "<<m<<" "<<j+1<<" "<<arr[j][low]<<"\n" , 0 ;
                }
                if(high != sz[j])
                {
                    if(arr[j][high] * 1ll >= a && arr[j][high] * 1ll < m)
                        cm = j , m = arr[j][high] ;
                }
                if(low >= 0)
                {
                    if(arr[j][low] * 1ll <= a && arr[j][low] * 1ll > l)
                        cl = j , l = arr[j][low] ;
                }
            }
        }
    }
    return cout<<"NIE\n" , 0 ;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...