답안 #258205

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
258205 2020-08-05T14:26:09 Z cheeheng Restore Array (RMI19_restore) C++14
7 / 100
15 ms 640 KB
#include <bits/stdc++.h>
using namespace std;

int A[25];

int l[10005];
int r[10005];
int k[10005];
int value[10005];

int main(){
    int N, M;
    scanf("%d%d", &N, &M);

    for(int i = 0; i < M; i ++){
        scanf("%d%d%d%d", &l[i], &r[i], &k[i], &value[i]);
    }

    for(int i = 0; i < (1<<N); i ++){
        for(int j = 0; j < N; j ++){
            A[j] = (i&(1<<j)) != 0;
        }

        bool boleh = true;
        for(int i = 0; i < M; i ++){
            int cnt0 = 0;
            for(int j = l[i]; j <= r[i]; j ++){
                cnt0 += (A[j] == 0);
            }
            if(cnt0 < k[i] && value[i] == 0){
                boleh = false;
                break;
            }else if(cnt0 >= k[i] && value[i] == 1){
                boleh = false;
                break;
            }
        }

        if(boleh){
            for(int i = 0; i < N; i ++){
                printf("%d ", A[i]);
            }
            return 0;
        }
    }

    printf("-1");
    return 0;
}

Compilation message

restore.cpp: In function 'int main()':
restore.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &M);
     ~~~~~^~~~~~~~~~~~~~~~
restore.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d%d", &l[i], &r[i], &k[i], &value[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 15 ms 512 KB Output is correct
6 Correct 7 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 15 ms 512 KB Output is correct
6 Correct 7 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Incorrect 11 ms 640 KB Output isn't correct
12 Halted 0 ms 0 KB -