# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
258083 | tqbfjotld | Restore Array (RMI19_restore) | C++14 | 21 ms | 896 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
value = 0 --> sum of range(l,r)<=r-l+1-k
value = 1 --> sum of range(l,r)>=r-l+1-k+1
*/
#include <bits/stdc++.h>
using namespace std;
typedef pair<pair<int,int>,pair<int,int> > query;
bool cmp(query a, query b){
int v1 = a.second.first==1&&a.second.second==1;
int v2 = b.second.first==1&&b.second.second==1;
if (v1!=v2) return v1>v2;
v1 = (a.second.first==a.first.second-a.first.first+1 && a.second.second==0);
v2 = (b.second.first==b.first.second-b.first.first+1 && b.second.second==0);
if (v1!=v2) return v1>v2;
return a<b;
}
int arr[50005];
vector<query> queries;
int main(){
int n,m;
scanf("%d%d",&n,&m);
for (int x = 0; x<m; x++){
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
queries.push_back({{a,b},{c,d}});
}
sort(queries.begin(),queries.end(),cmp);
for (auto x : queries){
//printf("%d %d %d %d\n",x);
int l = x.first.first;
int r = x.first.second;
int k = x.second.first;
int val = x.second.second;
if (k==1&&val==1){
for (int x = l; x<=r; x++){
arr[x] = 1;
}
continue;
}
if (k==r-l+1 && val==0){
for (int x = l; x<=r; x++){
if (arr[x]==1){
printf("-1");
return 0;
}
}
continue;
}
//if (val==0){
bool found = false;
for (int x = l; x<=r; x++){
if (val==arr[x]) found = true;
}
if (!found){
printf("-1");
return 0;
}
//}
}
for (int x = 0; x<n; x++){
printf("%d ",arr[x]);
}
}
컴파일 시 표준 에러 (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... |