답안 #120771

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120771 2019-06-25T12:32:42 Z popovicirobert Sticks (POI11_pat) C++14
100 / 100
197 ms 13896 KB
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

/*
const int MOD = ;

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}


inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}
*/

using namespace std;


int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, k;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> k;

    vector < vector <int> > arr(k + 1);
    for(i = 1; i <= k; i++) {
        int num;
        cin >> num;

        arr[i].resize(num + 1);
        for(int j = 1; j <= num; j++) {
            cin >> arr[i][j];
        }

        sort(next(arr[i].begin()), arr[i].end());
    }

    for(int col = 1; col <= k; col++) {
        for(auto it : arr[col]) {
            int mx1 = 0, mx2 = 0;
            int c1, c2;
            for(i = 1; i <= k; i++) {
                if(i != col) {
                    auto cur = upper_bound(arr[i].begin(), arr[i].end(), it) - arr[i].begin() - 1;
                    if(cur > 0) {
                        if(mx1 <= arr[i][cur]) {
                            mx2 = mx1, c2 = c1;
                            mx1 = arr[i][cur], c1 = i;
                        }
                        else if(mx2 < arr[i][cur]) {
                            mx2 = arr[i][cur], c2 = i;
                        }
                    }
                }
            }
            if(mx1 != 0 && mx2 != 0 && mx1 + mx2 > it) {
                cout << col << " " << it << " " << c1 << " " << mx1 << " " << c2 << " " << mx2;
                return 0;
            }
        }
    }

    cout << "NIE";

    //cin.close();
    //cout.close();
    return 0;
}

Compilation message

pat.cpp: In function 'int main()':
pat.cpp:76:85: warning: 'c2' may be used uninitialized in this function [-Wmaybe-uninitialized]
                 cout << col << " " << it << " " << c1 << " " << mx1 << " " << c2 << " " << mx2;
                                                                                     ^~~
pat.cpp:76:58: warning: 'c1' may be used uninitialized in this function [-Wmaybe-uninitialized]
                 cout << col << " " << it << " " << c1 << " " << mx1 << " " << c2 << " " << mx2;
                                                          ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Oczekiwano NIE
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Oczekiwano NIE
2 Correct 7 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Oczekiwano NIE
2 Correct 11 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Oczekiwano NIE
2 Correct 20 ms 1560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 640 KB Oczekiwano NIE
2 Correct 27 ms 2268 KB Output is correct
3 Correct 32 ms 1536 KB Oczekiwano NIE
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 1280 KB Oczekiwano NIE
2 Correct 46 ms 3704 KB Output is correct
3 Correct 53 ms 2168 KB Oczekiwano NIE
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 7160 KB Output is correct
2 Correct 68 ms 4472 KB Output is correct
3 Correct 74 ms 3320 KB Oczekiwano NIE
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 7164 KB Output is correct
2 Correct 78 ms 4984 KB Output is correct
3 Correct 115 ms 3984 KB Oczekiwano NIE
# 결과 실행 시간 메모리 Grader output
1 Correct 185 ms 13892 KB Output is correct
2 Correct 124 ms 5500 KB Output is correct
3 Correct 139 ms 5752 KB Oczekiwano NIE
# 결과 실행 시간 메모리 Grader output
1 Correct 185 ms 13896 KB Output is correct
2 Correct 81 ms 6520 KB Output is correct
3 Correct 197 ms 6840 KB Oczekiwano NIE