# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
258572 | dantoh000 | Restore Array (RMI19_restore) | C++14 | 18 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n,m;
int l[10005],r[10005],k[10005],val[10005];
int ans[10005];
int main(){
scanf("%d%d",&n,&m);
for (int i = 0; i < m; i++){
scanf("%d%d%d%d",&l[i],&r[i],&k[i],&val[i]);
}
if (n <= 18){
for (int mask = 0; mask < (1<<n); mask++){
bool can = 1;
for (int i = 0; i < m && can; i++){
int ct1 = 0;
for (int j = l[i]; j <= r[i] && can; j++){
if (mask&(1<<j)) ct1++;
}
int ct0 = r[i]-l[i]+1-ct1;
int chk = ct0 >= k[i] ? 0 : 1;
can &= (chk == val[i]);
}
if (can){
for (int i = 0; i < n; i++){
printf("%d ",(mask>>i)&1);
}
return 0;
}
}
printf("-1\n");
}
else{
for (int i = 0; i < m; i++){
if (k[i] != 1) return 0;
if (val[i] == 1){
for (int j = l[i]; j <= r[i]; j++){
ans[j] = 1;
}
}
}
for (int i = 0; i < m; i++){
if (val[i] == 0){
bool have = 0;
for (int j = l[i]; j <= r[i]; j++){
if (ans[j] == 0) have = 1;
}
if (!have){
printf("-1\n");
return 0;
}
}
}
for (int i = 0; i < n; i++){
printf("%d ",ans[i]);
}
}
}
컴파일 시 표준 에러 (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... |