Submission #481542

# Submission time Handle Problem Language Result Execution time Memory
481542 2021-10-21T06:23:15 Z SlavicG Restore Array (RMI19_restore) C++17
7 / 100
125 ms 460 KB
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long
 
#define       forn(i,n)              for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()
 
#define            pb                push_back
#define          sz(a)               (int)a.size()

void solve()
{ 
    int n, m;
    cin >> n >> m;

    vector<array<int, 4>> q(m);

    for(int i = 0;i < m;++i){
        int l, r, k, val;
        cin >> l >> r >> k >> val;
        q[i] = {l, r, k, val};
    }

    for(int mask = 0;mask < (1 << n);++mask){
        vector<int> a(n, 0);
        vector<int> p(n, 0);
        for(int i = 0;i < n;++i){
            if(mask & (1 << i))a[i] = 1;
            p[i] = a[i];
            if(i)p[i] += p[i - 1];
        }

        bool ok = true;
        for(int i = 0;i < m;++i){
            int l = q[i][0], r = q[i][1], k = q[i][2], val = q[i][3];

            int zeroes = (r - l + 1) - p[r];
            if(l)zeroes += p[l - 1];

            int number  = 0;
            if(zeroes >= k)number = 0;
            else number = 1;

            if(number != val)ok = false;
        }

        if(ok){
            forn(i, n)cout << a[i] << " ";
            cout << "\n";
            return;
        }
    }

    cout << "-1\n";
}
 
int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 31 ms 204 KB Output is correct
4 Correct 29 ms 204 KB Output is correct
5 Correct 125 ms 292 KB Output is correct
6 Correct 61 ms 204 KB Output is correct
7 Correct 26 ms 204 KB Output is correct
8 Correct 22 ms 204 KB Output is correct
9 Correct 118 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 31 ms 204 KB Output is correct
4 Correct 29 ms 204 KB Output is correct
5 Correct 125 ms 292 KB Output is correct
6 Correct 61 ms 204 KB Output is correct
7 Correct 26 ms 204 KB Output is correct
8 Correct 22 ms 204 KB Output is correct
9 Correct 118 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Incorrect 2 ms 460 KB Output isn't correct
12 Halted 0 ms 0 KB -