Submission #83677

# Submission time Handle Problem Language Result Execution time Memory
83677 2018-11-09T18:39:57 Z nikolapesic2802 Sticks (POI11_pat) C++14
68 / 100
723 ms 33792 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back

void fastscan(int &number)
{
    bool negative = false;
    register int c;

    number = 0;
    c = getchar();
    if (c=='-')
    {
        negative = true;
        c = getchar();
    }
    for (; (c>47 && c<58); c=getchar())
        number = number *10 + c - 48;
    if (negative)
        number *= -1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    //scanf("%i",&k);
    cin >> k;
    //fastscan(k);
    vector<set<int> > sets(k);
    for(int i=0;i<k;i++)
    {
        sets[i].insert(INT_MAX);
        int n;
        //scanf("%i",&n);
        //fastscan(n);
        cin >> n;
        for(int j=0;j<n;j++)
        {
            int a;
            //scanf("%i",&a);
            //fastscan(a);
            cin >> a;
            sets[i].insert(a);
        }
    }
    for(int i=0;i<k;i++)
    {
        for(auto p:sets[i])
        {
            if(p==INT_MAX)
                continue;
            int m1=INT_MAX,m2=INT_MAX,c1,c2;
            int ma1=-1,ma2=-1,ca1,ca2;
            for(int j=0;j<k;j++)
            {
                if(i==j)
                    continue;
                set<int>::iterator it=sets[j].lower_bound(p);
                int v=*it;
                if(v<m1)
                {
                    m2=m1;
                    c2=c1;
                    m1=v;
                    c1=j;
                }
                else
                {
                    if(v<m2)
                    {
                        m2=v;
                        c2=j;
                    }
                }
                if(it==sets[j].begin())
                    continue;
                it--;
                v=*it;
                if(v>ma1)
                {
                    ma2=ma1;
                    ca2=ca1;
                    ma1=v;
                    ca1=j;
                }
                else
                {
                    if(v>ma2)
                    {
                        ma2=v;
                        ca2=j;
                    }
                }
            }
            if(m1!=INT_MAX&&m2!=INT_MAX)
            {
                if(p+m1>m2)
                {
                    cout <<i+1<< " "<<p<< " "<<c1+1<< " "<<m1<< " "<<c2+1<< " "<<m2<< "\n";
                    //printf("%i %i %i %i %i %i\n",i+1,p,c1+1,m1,c2+1,m2);
                    return 0;
                }
            }
            if(ma1!=-1&&ma2!=-1)
            {
                if(ma1+ma2>p)
                {
                    cout <<i+1<< " "<<p<< " "<<ca1+1<< " "<<ma1<< " "<<ca2+1<< " "<<ma2<< "\n";
                    //printf("%i %i %i %i %i %i\n",i+1,p,ca1+1,ma1,ca2+1,ma2);
                    return 0;
                }
            }
        }
    }
    cout << "NIE" << "\n";
    return 0;
}

Compilation message

pat.cpp: In function 'int main()':
pat.cpp:112:80: warning: 'ca2' may be used uninitialized in this function [-Wmaybe-uninitialized]
                     cout <<i+1<< " "<<p<< " "<<ca1+1<< " "<<ma1<< " "<<ca2+1<< " "<<ma2<< "\n";
                                                                                ^~~
pat.cpp:112:56: warning: 'ca1' may be used uninitialized in this function [-Wmaybe-uninitialized]
                     cout <<i+1<< " "<<p<< " "<<ca1+1<< " "<<ma1<< " "<<ca2+1<< " "<<ma2<< "\n";
                                                        ^~~
pat.cpp:103:77: warning: 'c2' may be used uninitialized in this function [-Wmaybe-uninitialized]
                     cout <<i+1<< " "<<p<< " "<<c1+1<< " "<<m1<< " "<<c2+1<< " "<<m2<< "\n";
                                                                             ^~~
pat.cpp:103:55: warning: 'c1' may be used uninitialized in this function [-Wmaybe-uninitialized]
                     cout <<i+1<< " "<<p<< " "<<c1+1<< " "<<m1<< " "<<c2+1<< " "<<m2<< "\n";
                                                       ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 532 KB Output is correct
2 Correct 2 ms 556 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 2 ms 560 KB Oczekiwano NIE
2 Correct 17 ms 2412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2412 KB Oczekiwano NIE
2 Correct 28 ms 3272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 3272 KB Oczekiwano NIE
2 Correct 51 ms 6880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 6880 KB Oczekiwano NIE
2 Correct 86 ms 10908 KB Output is correct
3 Correct 101 ms 10908 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 72 ms 10908 KB Oczekiwano NIE
2 Correct 157 ms 19548 KB Output is correct
3 Correct 167 ms 19548 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Runtime error 405 ms 33792 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 346 ms 33792 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 723 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 569 ms 33792 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -