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