Submission #252199

#TimeUsernameProblemLanguageResultExecution timeMemory
252199BlagojceRestore Array (RMI19_restore)C++11
7 / 100
4 ms512 KiB
#include <bits/stdc++.h> #define fr(i, n, m) for(int i = (n); i < (m); i ++) #define pb push_back #define st first #define nd second #define pq priority_queue #define all(x) begin(x), end(x) #include <time.h> #include <cmath> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; const int i_inf = 1e9; const ll inf = 1e18; const ll mod = 1000000007; const ld eps = 1e-13; const ld pi = 3.14159265359; mt19937 _rand(time(NULL)); clock_t timer = clock(); const int mxn = 1e5; int n, m; int l[mxn], r[mxn], k[mxn], val[mxn]; void brute_force(){ int mat[n][n]; fr(i, 0, n){ int bit = 0; fr(j, i, n){ bit|=(1<<j); mat[i][j] = bit; } } int ANS = -1; fr(mask, 0, (1<<n)){ bool ok = true; fr(i, 0, m){ int len = r[i]-l[i]+1; int cnt = __builtin_popcount(mask&mat[l[i]][r[i]]); if(val[i] == 0 && k[i] > len-cnt){ ok = false; break; } if(val[i] == 1 && cnt < len - k[i]+1){ ok = false; break; } } if(ok){ ANS = mask; break; } } if(ANS == -1){ cout<<-1<<endl; } else{ fr(i, 0, n){ if(ANS&(1<<i)) cout<<1<<' '; else cout<<0<<' '; } cout<<endl; } } void solve(){ cin >> n >> m; fr(i, 0, m){ cin >> l[i] >> r[i] >> k[i] >> val[i]; } if(n < 20){ brute_force(); } else cout<<-1<<endl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...