QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#176252#7105. Pixel Artpengpeng_fudanWA 270ms20268kbC++142.1kb2023-09-11 13:32:502023-09-11 13:32:51

Judging History

你现在查看的是最新测评结果

  • [2023-09-11 13:32:51]
  • 评测
  • 测评结果:WA
  • 用时:270ms
  • 内存:20268kb
  • [2023-09-11 13:32:50]
  • 提交

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].push_back(b);
		}
	}
	for(int i=1;i<=n;i++)	sort(hi[i][0].begin(),hi[i][0].end());
	int black_num=0;
	int ltk=0;
	int len_num=0;
	int t=0;
	for(int i=1;i<=n;i++){
		t=t^1;
		sg[t].clear();
		for(auto j:ve[i])	black_num+=j.second-j.first+1;
		int sz=hi[i][0].size();
		for(int j=0;j<sz;j++){
			int p=hi[i][0][j];
			if(sg[t^1].query(1,1,m,p,p)||flag[p-1]);
			else ltk++;
			flag[p]=1;
			len_num++;		
		}
		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);
		}
		black_num+=len_num;
		cout<<black_num<<' '<<ltk<<'\n';
		for(auto j:hi[i][1]){
			sg[t^1].upd(1,1,m,j,j);
			len_num--;
			flag[j]=0;
		}
	}
}

signed main() {
	ios::sync_with_stdio(0),cin.tie(0);
	int _ = 1; 
	cin >> _;
	while(_--) solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 13540kb

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: 270ms
memory: 20268kb

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 50
200 50
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
9...

result:

wrong answer 10th lines differ - expected: '200 1', found: '200 51'