# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642921 | n3rm1n | Restore Array (RMI19_restore) | C++17 | 3 ms | 596 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN = 5005;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n, m;
int a[MAXN];
vector < pair < int, int > > v;
int p[MAXN];
void read()
{
cin >> n >> m;
int l, r, k, val;
for (int i = 1; i <= m; ++ i)
{
cin >> l >> r >> k >> val;
if(k == 1 && val == 1)
{
for (int j = l; j <= r; ++ j)
a[j] = 1;
}
else if(k == 1 && val == 0)
{
v.push_back(make_pair(l, r));
}
}
for (int i = 1; i <= n; ++ i)
{
p[i] = p[i-1] + a[i];
}
bool ok = true;
for (int i = 0; i < v.size() && false; ++ i)
{
int l = v[i].first, r = v[i].second;
if(p[r] - p[l-1] == r - l + 1)ok = false;
}
if(!ok)cout << -1 << endl;
else
{
for (int i = 1; i <= n; ++ i)
cout << a[i] << " ";
cout << endl;
}
}
int main()
{
speed();
read();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |