Submission #96054

# Submission time Handle Problem Language Result Execution time Memory
96054 2019-02-05T13:41:08 Z MohamedAhmed0 Sticks (POI11_pat) C++14
100 / 100
448 ms 4600 KB
#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 time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Oczekiwano NIE
2 Correct 14 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Oczekiwano NIE
2 Correct 23 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 404 KB Oczekiwano NIE
2 Correct 52 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 504 KB Oczekiwano NIE
2 Correct 85 ms 1016 KB Output is correct
3 Correct 58 ms 760 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 46 ms 720 KB Oczekiwano NIE
2 Correct 131 ms 1452 KB Output is correct
3 Correct 92 ms 1016 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 223 ms 2508 KB Output is correct
2 Correct 162 ms 1628 KB Output is correct
3 Correct 131 ms 1400 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 229 ms 2664 KB Output is correct
2 Correct 202 ms 1784 KB Output is correct
3 Correct 200 ms 1660 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 448 ms 4584 KB Output is correct
2 Correct 208 ms 2072 KB Output is correct
3 Correct 247 ms 2044 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 448 ms 4600 KB Output is correct
2 Correct 346 ms 2360 KB Output is correct
3 Correct 331 ms 2652 KB Oczekiwano NIE