답안 #331409

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
331409 2020-11-28T11:49:11 Z Sho10 Restore Array (RMI19_restore) C++14
0 / 100
9 ms 6380 KB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m,a[20],check=0;
struct kth{
int l,r,value,k;
};
kth b[100005];
void solve(ll pos,ll val){
    if(check==1){
        return;
    }
    a[pos]=val;
if(pos==n){
    for(ll i=1;i<=m;i++)
    {
        ll cnt=0;
        for(ll j=b[i].l;j<=b[i].r;j++)
        {
            if(a[j]==0){
                cnt++;
            }
        }
        if(b[i].value==0){
            if(cnt>b[i].k){
                a[pos]=-1;
                return;
            }
        }
        if(b[i].value==1){
            if(cnt>=b[i].k){
                a[pos]=-1;
                return;
            }
        }
    }
    check=1;
    for(ll i=1;i<=n;i++)
    {
        cout<<a[i]<<' ';
    }
    return;
}
solve(pos+1,0);
solve(pos+1,1);
a[pos]=-1;
return;
}
int32_t main(){
CODE_START;
cin>>n>>m;
for(ll i=1;i<=m;i++)
{
    cin>>b[i].l>>b[i].r>>b[i].k>>b[i].value;
    b[i].l++;
    b[i].r++;
}
solve(1,0);
solve(1,1);
if(check==1){
   return 0;
}
rc("-1");
}
/*
Subtask 1:
4 5
0 1 2 1
0 2 2 0
2 2 1 0
0 1 1 0
1 2 1 0
*/

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 6380 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 6380 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -