QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#601284#9303. Message Bombyeah14WA 3ms29740kbC++172.6kb2024-09-29 22:05:072024-09-29 22:05:07

Judging History

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

  • [2024-09-29 22:05:07]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:29740kb
  • [2024-09-29 22:05:07]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ull long long
#define PII  pair<int ,int>
const int INF = -1145141919810;
const int mod = 1e9 + 7;
const int N = 2e5+5;

//harbin;0 h;1,a;2 r;3 b;4 i;5 n
int ans[N];
map<int, bool>mp[N];
int cnt[N];
int cntt[N];
int L[N];
int LL[N][200];
int te[N];
map<PII, int>pl[N];
void solve() {
	int n, m, s;
	cin >> n >> m >> s;
	if(m/n>2500||n>199)
	{
		
		while (s--) {
			int op, x, y;
			cin >> op >> x >> y;
			if (op == 1) {
				if (cnt[y] != 0) {
					for (auto q = mp[y].begin(); q != mp[y].end(); q++) {
						ans[(*q).first] += cnt[y];
					}
				}
				cnt[y] = 0;
				mp[y][x] = 1;
			}
			else if (op == 2) {
				if (cnt[y] != 0) {
					for (auto q = mp[y].begin(); q != mp[y].end(); q++) {
						ans[(*q).first] += cnt[y];
					}
				}
				cnt[y] = 0;
				mp[y].erase(x);
			}
			else if (op == 3) {
				ans[x]--;
				cnt[y]++;
			}
		}
		for (int i = 1; i <= n; i++) {
			if (cnt[i] != 0) {
				for (auto q = mp[i].begin(); q != mp[i].end(); q++) {
					ans[(*q).first] += cnt[i];
				}
			}
		}
	}
	else {
		vector<vector<int>>p(n + 1);
		for (int i = 1; i <= n; i++)p[i].resize(s + 1);
		for(int i=1;i<=s;i++) {
			int op, x, y;
			cin >> op >> x >> y;
			if (op == 1) {
				LL[x][y] = i;
			}
			else if (op == 2) {
				pl[x][{ LL[x][y], i }] = y;
				LL[x][y] = -1;
			}
			else if (op == 3) {
				cnt[y]++;
				ans[x]--;
				p[y][i] = cnt[y];
			}
		}
		for (int i = 1; i <= m; i++) {
			for (int j = 1; j <= m; j++) {
				if (LL[i][j] >0)pl[i][{LL[i][j], s}] = j;
			}
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= s; j++) {
				if (p[i][j] == 0 && p[i][j - 1] != 0)p[i][j] = p[i][j - 1];
			}
		}
		for (int i = 1; i <= m; i++) {
			for (auto q = pl[i].begin(); q != pl[i].end(); q++) {
				int l = (*q).first.first, r = (*q).first.second;
				int y = (*q).second;
				ans[i] += p[y][r] - p[y][l - 1];
			}
		}
	}
	for (int i = 1; i <= m; i++)cout << ans[i] << "\n";
}
//&&(((sum[n]+k)%mid==0)||(sum[n]/mid!=(sum[n]+k)/mid)||(mid-(sum[n]%mid)>=k))
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int t=1;
	//cin >> t;
	//er(9e6);
	while (t--)solve();
	
}
//int n;
//cin >> n;
//for (int i = 1; i <= n; i++) {
//	cin >> a[i];
//}
//int maxx = 0, minn = INF;
//int sum = 0;
//for (int i = n; i <= 1; i++) {
//	sum += minn;
//	if (top == 0) {
//		minn = a[i];
//		st[top++] = a[i];
//	}
//	else {
//		if (a[i] > top && a[i] > minn)
//	}
//}
//cout << maxx - minn << endl;
//7 2 1 4 5 1 3 3
//4 1000 1000 1000 1000
//0

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3 10
1 3 2
1 3 1
1 1 2
1 2 1
3 1 2
2 3 1
3 3 2
3 2 1
3 3 2
3 2 1

output:

2
0
1

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 3ms
memory: 27112kb

input:

2 5 10
1 1 2
3 1 2
2 1 2
1 3 2
1 1 2
3 1 2
3 3 2
1 4 2
3 3 2
1 5 1

output:

2
0
1
1
0

result:

ok 5 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 28904kb

input:

10 100 1000
1 49 4
1 75 9
1 90 3
1 4 6
1 76 4
1 60 9
1 62 2
1 70 1
1 99 3
1 54 2
3 70 1
1 16 4
1 28 8
1 29 6
1 93 5
1 96 4
1 85 9
3 4 6
1 28 2
1 5 5
1 1 3
1 42 2
3 5 5
1 66 1
1 79 10
3 70 1
1 58 8
1 50 5
3 76 4
1 20 9
1 66 4
1 88 2
1 23 4
3 99 3
3 79 10
3 70 1
1 54 8
1 90 6
1 13 9
1 79 4
1 59 6
1 8 ...

output:

70
18
68
112
68
105
119
263
94
111
124
69
71
41
121
130
69
155
51
121
122
49
120
86
14
35
102
205
120
24
180
156
48
104
188
81
115
154
48
178
135
41
52
66
123
144
79
74
176
86
25
28
74
68
39
134
67
101
83
171
206
80
127
134
163
82
115
46
130
112
122
57
41
156
100
135
80
63
123
123
135
115
58
1
83
34...

result:

ok 100 lines

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 29740kb

input:

100 10 1000
1 9 47
1 1 79
1 5 61
1 2 89
1 6 37
1 7 35
1 4 45
1 6 13
1 8 44
3 2 89
3 7 35
3 5 61
3 4 45
1 10 72
1 8 87
1 9 95
1 1 21
1 6 96
3 6 37
1 7 57
3 9 47
1 10 60
3 1 79
3 8 44
1 4 14
3 10 60
3 9 95
3 10 60
1 2 12
1 3 60
3 8 87
3 9 47
1 3 78
1 7 53
3 8 87
3 8 44
3 7 35
1 2 3
1 4 46
3 3 60
1 8 5...

output:

-17
-20
-23
-6
-16
-28
4
-29
-20
-11

result:

wrong answer 1st lines differ - expected: '66', found: '-17'