답안 #857539

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
857539 2023-10-06T11:27:23 Z lbadea1000 Restore Array (RMI19_restore) C++17
13 / 100
518 ms 1104 KB
#include <bits/stdc++.h>
using namespace std;

const int NMAX = 5e3;
const int MMAX = 1e4;

int ans[NMAX];

struct op {
    int l, r, minimum, nr;
    bool active;
} v[MMAX];


int main() {
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int l, r, k, nr;
        cin >> l >> r >> k >> nr;
        if(nr == 0) {
            v[i] = {l, r, k, 0, true};
        } else {
            v[i] = {l, r, r - l + 1 - k + 1, 1, true};
        }
    }
    bool isPossible = true;
    for(int i = 0; i < n; i++) {
        int max0 = 0, max1 = 0;
        for(int j = 0; j < m; j++) {
            if(v[j].active) {
                if(v[j].l == i) {
                    if(v[j].nr == 0)
                        max0 = max(max0, v[j].minimum);
                    else max1 = max(max1, v[j].minimum);
                }
            }
        }
        if(max0 > max1) {
            ans[i] = 0;
        } else ans[i] = 1;
        for(int j = 0; j < m; j++) {
            if(v[j].active) {
                if(v[j].l == i) {
                    if(v[j].nr == ans[i])
                        v[j].minimum--;
                    v[j].l++;
                    if(v[j].l > v[j].r && v[j].minimum > 0)
                        isPossible = false;
                }
            }
        }
    }
    if(isPossible) {
        for(int i = 0; i < n; i++)
            cout << ans[i] << ' ';
    } else cout << -1;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 251 ms 600 KB Output is correct
2 Correct 272 ms 748 KB Output is correct
3 Correct 246 ms 1104 KB Output is correct
4 Correct 274 ms 856 KB Output is correct
5 Correct 439 ms 988 KB Output is correct
6 Correct 415 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 251 ms 600 KB Output is correct
2 Correct 272 ms 748 KB Output is correct
3 Correct 246 ms 1104 KB Output is correct
4 Correct 274 ms 856 KB Output is correct
5 Correct 439 ms 988 KB Output is correct
6 Correct 415 ms 600 KB Output is correct
7 Incorrect 518 ms 764 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -