QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#176210 | #7105. Pixel Art | pengpeng_fudan | WA | 243ms | 25244kb | C++14 | 2.0kb | 2023-09-11 12:33:44 | 2023-09-11 12:33:44 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
using ull=unsigned long long;
using ll=long long;
int n,m,k;
vector<pair<int,int>> ve[100010];
vector<int> hi[100010][2];
struct seg{
#define ls(x) tr[x].l
#define rs(x) tr[x].r
#define fu(x) tr[x].fu
struct node{
int l,r;bool fu;
}tr[100010*2];
int tot=1;
void clear(int x){ls(x)=rs(x)=fu(x)=0;}
seg(){tot=1,clear(1);}
void clear(){tot=1,clear(1);}
void upd(int x,int l,int r,int L,int R){
if(L<=l&&r<=R){fu(x)=1;return ;}
int mid=(l+r)>>1;
if(mid>=L){
if(!ls(x)){ls(x)=++tot;clear(tot);}
upd(ls(x),l,mid,L,R);
}
if(mid<R){
if(!rs(x)){rs(x)=++tot;clear(tot);}
upd(rs(x),mid+1,r,L,R);
}
}
bool query(int x,int l,int r,int L,int R){
if(fu(x)) return true;
int mid=(l+r)>>1;
bool ans=0;
if(mid>=L&&ls(x)) ans|=query(ls(x),l,mid,L,R);
if(mid<R&&rs(x)) ans|=query(rs(x),mid+1,r,L,R);
return ans;
}
};
seg sg[2];
bool flag[100010];
void solve() {
cin>>n>>m>>k;
fill(flag,flag+m+2,0);
sg[0].clear(),sg[1].clear();
for(int i=1;i<=n;i++){
ve[i].clear();
hi[i][0].clear(),hi[i][1].clear();
}
int a,b,c,d;
for(int i=1;i<=k;i++){
cin>>a>>b>>c>>d;
if(a==c) ve[a].push_back({b,d});
else{
hi[a][0].push_back(b);
hi[c+1][1].push_back(b);
}
}
int black_num=0;
int ltk=0;
int len_num=0;
int t=0;
for(int i=1;i<=n;i++){
t=t^1;
for(auto j:ve[i]) black_num+=j.second-j.first+1;
len_num=len_num+hi[i][0].size()-hi[i][1].size();
black_num+=len_num;
for(auto j:hi[i][0]){
if(sg[t^1].query(1,1,m,j,j)||flag[j]);
else ltk++;
}
for(auto j:hi[i][1]) flag[j]=0;
for(auto j:hi[i][0]) flag[j]=1;
for(auto j:ve[i]){
if(!sg[t^1].query(1,1,m,j.first,j.second)&&!flag[j.first-1]&&!flag[j.second+1]) ltk++;
sg[t].upd(1,1,m,j.first,j.second);
}
cout<<black_num<<' '<<ltk<<'\n';
}
}
signed main() {
ios::sync_with_stdio(0),cin.tie(0);
int _ = 1;
cin >> _;
while(_--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 13424kb
input:
3 2 5 2 1 1 1 2 2 3 2 5 2 5 2 1 1 1 3 2 3 2 5 3 3 3 1 1 1 2 3 1 3 2 1 3 2 3
output:
2 1 5 2 3 1 6 1 3 1 4 1 6 2
result:
ok 7 lines
Test #2:
score: -100
Wrong Answer
time: 243ms
memory: 25244kb
input:
2130 2 5 2 1 1 1 2 2 3 2 5 2 5 2 1 1 1 3 2 3 2 5 3 3 3 1 1 1 2 3 1 3 2 1 3 2 3 3 100 51 1 2 2 2 1 4 2 4 1 6 2 6 1 8 2 8 1 10 2 10 1 12 2 12 1 14 2 14 1 16 2 16 1 18 2 18 1 20 2 20 1 22 2 22 1 24 2 24 1 26 2 26 1 28 2 28 1 30 2 30 1 32 2 32 1 34 2 34 1 36 2 36 1 38 2 38 1 40 2 40 1 42 2 42 1 44 2 44 ...
output:
2 1 5 2 3 1 6 1 3 1 4 1 6 2 50 50 100 50 200 51 50 50 150 100 200 100 2 1 4 1 6 1 8 1 10 1 12 1 14 1 16 1 18 1 20 1 22 1 24 1 26 1 28 1 30 1 32 1 34 1 36 1 38 1 40 1 42 1 44 1 46 1 48 1 50 1 52 1 54 1 56 1 58 1 60 1 62 1 64 1 66 1 68 1 70 1 72 1 74 1 76 1 78 1 80 1 82 1 84 1 86 1 88 1 90 1 92 1 94 1...
result:
wrong answer 10th lines differ - expected: '200 1', found: '200 51'