Submission #96051

# Submission time Handle Problem Language Result Execution time Memory
96051 2019-02-05T13:12:24 Z MohamedAhmed0 Sticks (POI11_pat) C++14
100 / 100
211 ms 6952 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 ;

int readInt () {
	bool minus = false;
	int result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

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 ;
    n = readInt();
    for(int i = 0 ; i < n ; ++i)
    {
        sz[i] = readInt();
        for(int j = 0 ; j < sz[i] ; ++j)
            arr[i][j] = readInt();
        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 6 ms 476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Oczekiwano NIE
2 Correct 12 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Oczekiwano NIE
2 Correct 25 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 504 KB Oczekiwano NIE
2 Correct 44 ms 1016 KB Output is correct
3 Correct 33 ms 1784 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 27 ms 756 KB Oczekiwano NIE
2 Correct 64 ms 1400 KB Output is correct
3 Correct 52 ms 2168 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 72 ms 2556 KB Output is correct
2 Correct 79 ms 1660 KB Output is correct
3 Correct 72 ms 3192 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 72 ms 2552 KB Output is correct
2 Correct 105 ms 1784 KB Output is correct
3 Correct 106 ms 4088 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 149 ms 4600 KB Output is correct
2 Correct 91 ms 2040 KB Output is correct
3 Correct 135 ms 2116 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 147 ms 4596 KB Output is correct
2 Correct 211 ms 2324 KB Output is correct
3 Correct 194 ms 6952 KB Oczekiwano NIE