Submission #258208

# Submission time Handle Problem Language Result Execution time Memory
258208 2020-08-05T14:32:05 Z cheeheng Restore Array (RMI19_restore) C++14
20 / 100
600 ms 640 KB
#include <bits/stdc++.h>
using namespace std;

int A[10005];

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

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

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

    if(subtask2){
        for(int i = 0; i < M; i ++){
            if(value[i] == 1){
                for(int k = l[i]; k <= r[i]; k ++){
                    A[k] = 1;
                }
            }
        }

        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]);
            }
            printf("\n");
            //return 0;
        }else{
            printf("-1\n");
        }
        return 0;
    }

    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:17: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]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 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 24 ms 384 KB Output is correct
6 Correct 7 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 8 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 512 KB Output is correct
2 Correct 16 ms 640 KB Output is correct
3 Correct 16 ms 640 KB Output is correct
4 Correct 16 ms 640 KB Output is correct
5 Correct 6 ms 640 KB Output is correct
6 Correct 8 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 512 KB Output is correct
2 Correct 16 ms 640 KB Output is correct
3 Correct 16 ms 640 KB Output is correct
4 Correct 16 ms 640 KB Output is correct
5 Correct 6 ms 640 KB Output is correct
6 Correct 8 ms 640 KB Output is correct
7 Execution timed out 1071 ms 640 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 24 ms 384 KB Output is correct
6 Correct 7 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 8 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 16 ms 640 KB Output is correct
13 Correct 16 ms 640 KB Output is correct
14 Correct 16 ms 640 KB Output is correct
15 Correct 6 ms 640 KB Output is correct
16 Correct 8 ms 640 KB Output is correct
17 Execution timed out 1071 ms 640 KB Time limit exceeded
18 Halted 0 ms 0 KB -