Submission #26744

# Submission time Handle Problem Language Result Execution time Memory
26744 2017-07-05T11:04:08 Z model_code Sticks (POI11_pat) C++14
0 / 100
343 ms 13548 KB
/*************************************************************************
 *                                                                       *
 *                    XVIII Olimpiada Informatyczna                      *
 *                                                                       *
 *   Zadanie:           Patyczki                                         *
 *   Autor:             Miroslaw Michalski                               *
 *   Zlozonosc czasowa: O(n * lg(n))                                     *
 *   Opis:              Rozwiazanie weryfikujace                         *
 *                                                                       *
 *************************************************************************/

#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

inline bool triangle(const int a, const int b, const int c) {
    return (a + b > c && a + c > b && b + c > a);
}

inline bool diff(const int a, const int b, const int c) {
    return (a != b && a != c && b != c);
}

size_t n;

// zwraca element z pozycji >= pos tze jego kolor jest rowny 
// kolorowi pos
size_t analBlock(const vector<pair<int, int> >& v, size_t pos) {
    int currColor = v[pos].second;
    while (pos + 1 < n && v[pos + 1].second == currColor) {
        pos++;
    }
    return pos;
}

int main() {
    int k, il, x;
    vector<pair<int, int> > v;

    scanf("%d", &k);
    for(int c = 1; c <= k; c++) {
        scanf("%d", &il);
        for(int i = 0; i < il; i++) {
            scanf("%d", &x);
            v.push_back(make_pair(x, c));
        }
    }
    sort(v.begin(), v.end());
    n = v.size();
    v.push_back(make_pair(-1, -1));

    bool done = false;
    size_t pos = 0;
    while (!done) {
        size_t p1 = analBlock(v, pos);
        size_t p2 = analBlock(v, p1 + 1);
        size_t p3 = p2 + 1;
        pos = p2;
        if (p1 < n && p2 < n && p3 < n) {
            if (triangle(v[p1].first, v[p2].first, v[p3].first) && 
                    diff(v[p1].second, v[p2].second, v[p3].second)) {
                printf("%d %d %d %d %d %d\n", v[p1].first, v[p1].second, 
                        v[p2].second, v[p2].first, v[p3].second, v[p3].first);
                return 0;
            }
        } else {
            done = true;
        }
    }
    printf("NIE\n");
    return 0;
}

Compilation message

pat.cpp: In function 'int main()':
pat.cpp:42:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &k);
                    ^
pat.cpp:44:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &il);
                         ^
pat.cpp:46:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &x);
                            ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1176 KB Z wypisanych patyczkow nie da sie utworzyc trojkata
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1176 KB Integer 51 violates the range [1, 50]
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1176 KB Z wypisanych patyczkow nie da sie utworzyc trojkata
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1176 KB Integer 58 violates the range [1, 50]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1176 KB Oczekiwano NIE
2 Incorrect 6 ms 1644 KB Integer 20722 violates the range [1, 50]
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1176 KB Oczekiwano NIE
2 Incorrect 9 ms 2028 KB Integer 27744 violates the range [1, 50]
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1316 KB Oczekiwano NIE
2 Incorrect 26 ms 2796 KB Integer 77303 violates the range [1, 50]
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1644 KB Oczekiwano NIE
2 Incorrect 36 ms 4332 KB Integer 121978 violates the range [1, 50]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2796 KB Oczekiwano NIE
2 Incorrect 73 ms 7404 KB Integer 498264 violates the range [1, 50]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 159 ms 7404 KB Integer 729 violates the range [1, 50]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 163 ms 7404 KB Integer 1802 violates the range [1, 50]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 299 ms 13548 KB Integer 1315 violates the range [1, 50]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 343 ms 13548 KB Integer 3399 violates the range [1, 50]
2 Halted 0 ms 0 KB -