#include <bits/stdc++.h>
#define stop system("pause")
#define stop2 char o; cin >> o
#define INP freopen("pcb.in","r",stdin)
#define OUTP freopen ("pcb.out","w",stdout)
//#define int long long
using namespace std;
const int maxn = 100004;
vector<vector<int> > v;
main(){
ios_base::sync_with_stdio(0);
int n,m,k; cin >> n >> m >> k;
v.resize(n+2);
for(int i(0); i < k;i++){
int a,b; cin >> a >> b;
v[a].push_back(b);
}
int ans = 0;
for(int l(1);l<=n;l++){
set<int> s;
int bad = 0;
for(int r(l);r<=n;r++){
for(int z(0); z < v[r].size();z++)s.insert(v[r][z]);
if(!v[r].size())bad++;
if(s.size()==m && s.size()<=(r-l+1)-bad){
ans++;
//cout << l << ' ' << r << ' ' << s.size() << endl;
}
}
}
cout << ans;
return 0;
}
/*
10 4
1 5 5 5 10 4 4 2 3 1
*/
Compilation message
marriage.cpp:13:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
marriage.cpp: In function 'int main()':
marriage.cpp:26:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int z(0); z < v[r].size();z++)s.insert(v[r][z]);
~~^~~~~~~~~~~~~
marriage.cpp:28:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(s.size()==m && s.size()<=(r-l+1)-bad){
~~~~~~~~^~~
marriage.cpp:28:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(s.size()==m && s.size()<=(r-l+1)-bad){
~~~~~~~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
380 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
15 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
16 |
Correct |
2 ms |
380 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
8 ms |
376 KB |
Output is correct |
20 |
Correct |
4 ms |
376 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
376 KB |
Output is correct |
24 |
Correct |
3 ms |
380 KB |
Output is correct |
25 |
Correct |
162 ms |
600 KB |
Output is correct |
26 |
Incorrect |
42 ms |
376 KB |
Output isn't correct |
27 |
Correct |
11 ms |
376 KB |
Output is correct |
28 |
Correct |
5 ms |
376 KB |
Output is correct |
29 |
Correct |
43 ms |
532 KB |
Output is correct |
30 |
Correct |
37 ms |
504 KB |
Output is correct |
31 |
Execution timed out |
1560 ms |
632 KB |
Time limit exceeded |
32 |
Incorrect |
223 ms |
528 KB |
Output isn't correct |
33 |
Correct |
28 ms |
376 KB |
Output is correct |
34 |
Correct |
28 ms |
376 KB |
Output is correct |
35 |
Correct |
779 ms |
1016 KB |
Output is correct |
36 |
Correct |
589 ms |
1068 KB |
Output is correct |
37 |
Execution timed out |
1579 ms |
888 KB |
Time limit exceeded |
38 |
Execution timed out |
1546 ms |
1272 KB |
Time limit exceeded |
39 |
Correct |
1212 ms |
760 KB |
Output is correct |
40 |
Execution timed out |
1568 ms |
888 KB |
Time limit exceeded |
41 |
Execution timed out |
1557 ms |
1016 KB |
Time limit exceeded |
42 |
Execution timed out |
1549 ms |
1144 KB |
Time limit exceeded |
43 |
Execution timed out |
1578 ms |
1144 KB |
Time limit exceeded |
44 |
Execution timed out |
1570 ms |
1400 KB |
Time limit exceeded |
45 |
Execution timed out |
1571 ms |
1784 KB |
Time limit exceeded |
46 |
Execution timed out |
1563 ms |
2168 KB |
Time limit exceeded |
47 |
Execution timed out |
1575 ms |
2040 KB |
Time limit exceeded |
48 |
Execution timed out |
1577 ms |
2044 KB |
Time limit exceeded |
49 |
Execution timed out |
1557 ms |
2424 KB |
Time limit exceeded |
50 |
Execution timed out |
1576 ms |
1272 KB |
Time limit exceeded |