# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1089038 | vjudge1 | Izbori (COCI17_izbori) | C++17 | 201 ms | 432 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/* https://oj.uz/problem/view/COCI17_izbori?locale=en: WA */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
unsigned int popcnt(unsigned int x) {
unsigned int out = 0;
while (x) {
++out;
x &= x - 1;
}
return out;
}
int main(void) {
unsigned int N, M, K, i;
unsigned int *priorities;
unsigned int *scores;
unsigned int best;
(void) scanf("%u %u %u", &N, &M, &K);
best = M - 1;
priorities = (unsigned int *) calloc(N*M, sizeof(*priorities));
scores = (unsigned int *) calloc(M, sizeof(*scores));
for (i = 0; i < N*M; ++i)
(void) scanf(" %u", &priorities[i]);
for (i = 0; i < (1 << M)-1; ++i) {
unsigned int j, k, l;
memset(scores, 0, sizeof(*scores) * M);
for (j = 0; j < N; ++j) {
l = M;
for (k = 0; k < M; ++k)
if ((~i & (1<<(priorities[j*M+k]-1))) && l == M)
l = priorities[j*M+k]-1;
++scores[l];
}
k = 0;
for (j = 1; j < M; ++j)
if (scores[j] > scores[k])
k = j;
if (i == 0)
printf("%u\n", k + 1);
if (k == K-1)
best = popcnt(i);
}
printf("%u\n", best);
return EXIT_SUCCESS;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |