#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)-bad){
ans++;
}
}
}
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)-bad){
~~~~~~~~^~~
marriage.cpp:28:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(s.size()==m && s.size()<=(r-l)-bad){
~~~~~~~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
14 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
15 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
16 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
17 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
18 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
19 |
Incorrect |
8 ms |
376 KB |
Output isn't correct |
20 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
23 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
24 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
25 |
Incorrect |
160 ms |
596 KB |
Output isn't correct |
26 |
Incorrect |
40 ms |
504 KB |
Output isn't correct |
27 |
Correct |
12 ms |
376 KB |
Output is correct |
28 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
29 |
Correct |
43 ms |
504 KB |
Output is correct |
30 |
Correct |
36 ms |
508 KB |
Output is correct |
31 |
Execution timed out |
1569 ms |
632 KB |
Time limit exceeded |
32 |
Incorrect |
222 ms |
552 KB |
Output isn't correct |
33 |
Correct |
28 ms |
472 KB |
Output is correct |
34 |
Incorrect |
27 ms |
376 KB |
Output isn't correct |
35 |
Incorrect |
746 ms |
1732 KB |
Output isn't correct |
36 |
Incorrect |
589 ms |
1656 KB |
Output isn't correct |
37 |
Execution timed out |
1572 ms |
1272 KB |
Time limit exceeded |
38 |
Execution timed out |
1574 ms |
2040 KB |
Time limit exceeded |
39 |
Incorrect |
1212 ms |
760 KB |
Output isn't correct |
40 |
Execution timed out |
1583 ms |
1016 KB |
Time limit exceeded |
41 |
Execution timed out |
1572 ms |
1144 KB |
Time limit exceeded |
42 |
Execution timed out |
1564 ms |
1400 KB |
Time limit exceeded |
43 |
Execution timed out |
1570 ms |
1784 KB |
Time limit exceeded |
44 |
Execution timed out |
1566 ms |
2172 KB |
Time limit exceeded |
45 |
Execution timed out |
1569 ms |
2040 KB |
Time limit exceeded |
46 |
Execution timed out |
1577 ms |
2808 KB |
Time limit exceeded |
47 |
Execution timed out |
1557 ms |
3064 KB |
Time limit exceeded |
48 |
Execution timed out |
1571 ms |
2936 KB |
Time limit exceeded |
49 |
Execution timed out |
1571 ms |
3192 KB |
Time limit exceeded |
50 |
Execution timed out |
1569 ms |
1272 KB |
Time limit exceeded |