답안 #845029

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845029 2023-09-06T11:22:24 Z M_W_13 Cheerleaders (info1cup20_cheerleaders) C++17
0 / 100
113 ms 16024 KB
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        int n, k;
        cin >> n >> k;
        if (k == 1) {
            int klasy[n];
            int suma = 0;
            for (int x = 0; x< n; x++) {
                cin >> klasy[x];
                suma += klasy[x];
            }
            if (suma % 2 == 0) {
                cout << "0";
            }
            else {
                cout << "1";
            }
        }
        else {
            int log = 0;
            while ((1 << log) < k) {
                log++;
            }
            if ((1 << log) > k) {
                log--;
            }
            int klasy[n];
            long long potegi[n][log + 1];
            for (int x = 0; x < n; x++) {
                cin >> klasy[x];
                for (int l = 0; l < log + 1; l++) {
                    if (klasy[x] % (1 << l) == 0) {
                        potegi[x][l] = klasy[x]/(1 << l);
                    }
                    else {
                        potegi[x][l] = 0;
                    }
                }
            }
            int suma;
            for (int l = 0; l < log + 1; l++) {
                suma = 0;
                for (int x = 0; x < n; x++) {
                    suma += potegi[x][l];
                }
                if (suma % 2 == 1) {
                    cout << "1";
                    break;
                }
            }
            if (suma % 2 == 0) {
                cout << "0";
            }
    }
    }
    return 0;
}

Compilation message

cheerleaders.cpp: In function 'int main()':
cheerleaders.cpp:59:26: warning: 'suma' may be used uninitialized in this function [-Wmaybe-uninitialized]
   59 |             if (suma % 2 == 0) {
      |                 ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Wrong number of inversions
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Wrong number of inversions
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 3256 KB Wrong number of inversions
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 113 ms 16024 KB Wrong number of inversions
2 Halted 0 ms 0 KB -