QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#112188 | #1147. Wall | minhcool | 0 | 14ms | 112952kb | C++17 | 2.7kb | 2023-06-10 15:46:54 | 2023-06-10 15:46:57 |
Judging History
answer
#include "wall.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
//#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const int N = 2e6 + 5;
const int oo = 1e9 + 7, mod = 1e9 + 7;
mt19937 rng(1);
int rnd(int l, int r){
int temp = rng() % (r - l + 1);
return abs(temp) + l;
}
int n, q;
struct it{
// lst1 = last max operation, lst2 = last min operation, which = which type?
int lst1, lst2;// which;
it(){
lst1 = -oo, lst2 = oo;// which = -1;
}
it(int _a, int _b){
lst1 = _a, lst2 = _b;
}
}IT[N << 2];
it merge(it x, it y){
it z;
assert(x.lst1 <= x.lst2);
assert(y.lst1 <= y.lst2);
ii temp = {x.lst1, x.lst2};
if(y.lst1 >= x.lst2){
temp = {y.lst1, y.lst1};
}
else temp = {max(x.lst1, y.lst1), temp.se};
if(y.lst2 <= temp.fi) temp = {y.lst2, y.lst2};
else temp = {temp.fi, min(temp.se, y.lst2)};
z.lst1 = temp.fi, z.lst2 = temp.se;
return z;
}
void upd(int id, int l, int r, int pos, ii para){
if(l == r){
if(para.fi == 0){
IT[id].lst1 = para.se;
// IT[id].which = 0;
}
else if(para.fi == 1){
IT[id].lst2 = para.se;
// IT[id].which = 1;
}
else{// cook
IT[id].lst1 = -oo, IT[id].lst2 = oo; //IT[id].which = -1;
}
return;
}
int mid = (l + r) >> 1;
if(pos <= mid) upd(id << 1, l, mid, pos, para);
else upd(id << 1 | 1, mid + 1, r, pos, para);
IT[id] = merge(IT[id << 1], IT[id << 1 | 1]);
}
vector<ii> updates[N];
void buildWall(int N, int K, int op[], int left[], int right[], int height[], int finalHeight[]){
n = N, q = K;
for(int i = 0; i < q; i++){
cout << "OK " << left[i] << " " << right[i] << "\n";
updates[left[i]].pb({i, 1});
updates[right[i] + 1].pb({i, -1});
}
for(int i = 0; i < n; i++){
for(auto it : updates[i]){
// cout << "HEHE " << it.fi << " " << it.se << " " << i << "\n";
if(it.se == 1){
upd(1, 0, q - 1, it.fi, {op[it.fi] - 1, height[it.fi]});
}
else{
upd(1, 0, q - 1, it.fi, {-1, -oo});
}
}
it a = {0, 0}, b = IT[1];
finalHeight[i] = merge(a, b).lst1;
cout << finalHeight[i] << " ";
}
// cout << "\n";
}
// local part, when submit just erase the #define local line
//#define local
#ifdef local
void process(){
int n, k, op[10005], left[10005], right[10005], height[10005], finalheight[10005];
cin >> n >> k;
for(int i = 0; i < k; i++) cin >> op[i] >> left[i] >> right[i] >> height[i];
buildWall(n, k, op, left, right, height, finalheight);
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
process();
}
#endif
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 14ms
memory: 112952kb
input:
1 1 1 0 0 79348
output:
OK 0 0 79348 79348
result:
wrong answer 1st lines differ - expected: '79348', found: 'OK 0 0'
Subtask #2:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 14ms
memory: 112952kb
input:
1 1 1 0 0 51569
output:
OK 0 0 51569 51569
result:
wrong answer 1st lines differ - expected: '51569', found: 'OK 0 0'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%