| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 238363 | Sorting | Restore Array (RMI19_restore) | C++14 | 23 ms | 560 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int k_N = 5000 + 3;
const int k_M = 10000 + 3;
struct Constraint{
int l, r, k, value;
int cnt;
Constraint(){}
Constraint(int l, int r, int k, int value){
this->l = l;
this->r = r;
this->k = k;
this->value = value;
}
void set_cnt(){
if(!value)
cnt = k;
else
cnt = (r - l + 1) - k + 1;
}
};
int n, m;
int a[k_N];
Constraint c[k_M];
int prefix[k_N];
int get_count_ones(int l, int r){
if(l == 0)
return prefix[r];
return prefix[r] - prefix[l - 1];
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
for(int i = 0; i < m; ++i){
cin >> c[i].l >> c[i].r >> c[i].k >> c[i].value;
c[i].set_cnt();
}
for(int i = 0; i < n; ++i)
a[i] = -1;
sort(c, c + m, [](const Constraint &lvalue, const Constraint &rvalue){
if((lvalue.r - lvalue.l + 1) - lvalue.cnt != (rvalue.r - rvalue.l + 1) - rvalue.cnt)
return (lvalue.r - lvalue.l + 1) - lvalue.cnt < (rvalue.r - rvalue.l + 1) - rvalue.cnt;
if(lvalue.r - lvalue.l != rvalue.r - rvalue.l)
return (lvalue.r - lvalue.l) < (rvalue.r - rvalue.l);
return lvalue.l < rvalue.l;
});
for(int _ = 0; _ < m; ++_){
auto [l, r, k, value, cnt] = c[_];
//cout << l << " " << r << " " << k << " " << value << " " << cnt << "\n";
int curr_cnt = 0;
for(int i = l; i <= r; ++i)
if(a[i] == value)
++curr_cnt;
if(curr_cnt >= cnt)
continue;
for(int i = l; i <= r; ++i){
if(a[i] == -1){
a[i] = value;
curr_cnt++;
if(curr_cnt == cnt)
break;
}
}
if(curr_cnt != cnt){
cout << "-1\n";
return 0;
}
}
for(int i = 0; i < n; ++i)
a[i] = (a[i] == -1) ? 0 : a[i];
for(int i = 0; i < n; ++i)
cout << a[i] << " ";
cout << "\n";
}
컴파일 시 표준 에러 (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... | ||||
