답안 #258572

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
258572 2020-08-06T07:18:50 Z dantoh000 Restore Array (RMI19_restore) C++14
20 / 100
18 ms 512 KB
#include <bits/stdc++.h>
using namespace std;
int n,m;
int l[10005],r[10005],k[10005],val[10005];
int ans[10005];
int main(){
    scanf("%d%d",&n,&m);
    for (int i = 0; i < m; i++){
        scanf("%d%d%d%d",&l[i],&r[i],&k[i],&val[i]);
    }
    if (n <= 18){
        for (int mask = 0; mask < (1<<n); mask++){
            bool can = 1;
            for (int i = 0; i < m && can; i++){
                int ct1 = 0;
                for (int j = l[i]; j <= r[i] && can; j++){
                    if (mask&(1<<j)) ct1++;
                }
                int ct0 = r[i]-l[i]+1-ct1;
                int chk = ct0 >= k[i] ? 0 : 1;
                can &= (chk == val[i]);
            }
            if (can){
                for (int i = 0; i < n; i++){
                    printf("%d ",(mask>>i)&1);
                }
                return 0;
            }
        }
        printf("-1\n");

    }
    else{
        for (int i = 0; i < m; i++){
            if (k[i] != 1) return 0;
            if (val[i] == 1){
                for (int j = l[i]; j <= r[i]; j++){
                    ans[j] = 1;
                }
            }
        }
        for (int i = 0; i < m; i++){
            if (val[i] == 0){
                bool have = 0;
                for (int j = l[i]; j <= r[i]; j++){
                    if (ans[j] == 0) have = 1;
                }
                if (!have){
                    printf("-1\n");
                    return 0;
                }
            }
        }
        for (int i = 0; i < n; i++){
            printf("%d ",ans[i]);
        }

    }
}

Compilation message

restore.cpp: In function 'int main()':
restore.cpp:7: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:9: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],&val[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 11 ms 384 KB Output is correct
6 Correct 5 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 5 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 512 KB Output is correct
2 Correct 18 ms 512 KB Output is correct
3 Correct 17 ms 512 KB Output is correct
4 Correct 18 ms 512 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 512 KB Output is correct
2 Correct 18 ms 512 KB Output is correct
3 Correct 17 ms 512 KB Output is correct
4 Correct 18 ms 512 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Incorrect 4 ms 512 KB Unexpected end of file - int32 expected
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 11 ms 384 KB Output is correct
6 Correct 5 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 5 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 16 ms 512 KB Output is correct
12 Correct 18 ms 512 KB Output is correct
13 Correct 17 ms 512 KB Output is correct
14 Correct 18 ms 512 KB Output is correct
15 Correct 6 ms 512 KB Output is correct
16 Correct 6 ms 512 KB Output is correct
17 Incorrect 4 ms 512 KB Unexpected end of file - int32 expected
18 Halted 0 ms 0 KB -