#include<bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()
#define ll long long
#define pb push_back
#define nl '\n'
#define popb pop_back()
#define sz size()
#define ld long double
#define ull unsigned long long
#define F first
#define S second
#define fix fixed<<setprecision
#define pii pair<int,int>
#define E exit (0)
#define int long long
const int inf=1e9;
map<int,bool>was;
map<int,vector<int>>s;
int n,m,k;
bool f(int pos,int l,int r) {
if (pos==m+1) {
return true;
}
bool ok=false;
for (auto e:s[pos]) {
if (was[e]==false&&e>=l&&e<=r) {
was[e]=true;
ok=max(ok,f(pos+1,l,r));
was[e]=false;
}
}
return ok;
}
signed main() {
//freopen("planting.in","r",stdin);
//freopen("planting.out","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
srand(time(0));
cin>>n>>m>>k;
for (int i=1;i<=k;i++) {
int a,b;
cin>>a>>b;
s[b].pb(a);
}
int ans=0;
for (int i=1;i<=n;i++) {
for (int j=i;j<=n;j++) {
ans+=(f(1,i,j)==true?1:0);
}
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Execution timed out |
1572 ms |
364 KB |
Time limit exceeded |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Execution timed out |
1542 ms |
364 KB |
Time limit exceeded |
15 |
Correct |
188 ms |
492 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
18 ms |
512 KB |
Output is correct |
18 |
Correct |
2 ms |
364 KB |
Output is correct |
19 |
Execution timed out |
1575 ms |
364 KB |
Time limit exceeded |
20 |
Execution timed out |
1578 ms |
364 KB |
Time limit exceeded |
21 |
Execution timed out |
1565 ms |
364 KB |
Time limit exceeded |
22 |
Correct |
92 ms |
396 KB |
Output is correct |
23 |
Execution timed out |
1577 ms |
364 KB |
Time limit exceeded |
24 |
Execution timed out |
1559 ms |
364 KB |
Time limit exceeded |
25 |
Execution timed out |
1564 ms |
492 KB |
Time limit exceeded |
26 |
Execution timed out |
1544 ms |
512 KB |
Time limit exceeded |
27 |
Execution timed out |
1574 ms |
364 KB |
Time limit exceeded |
28 |
Execution timed out |
1553 ms |
364 KB |
Time limit exceeded |
29 |
Execution timed out |
1543 ms |
520 KB |
Time limit exceeded |
30 |
Execution timed out |
1574 ms |
492 KB |
Time limit exceeded |
31 |
Execution timed out |
1563 ms |
1004 KB |
Time limit exceeded |
32 |
Execution timed out |
1564 ms |
492 KB |
Time limit exceeded |
33 |
Correct |
9 ms |
364 KB |
Output is correct |
34 |
Execution timed out |
1573 ms |
504 KB |
Time limit exceeded |
35 |
Execution timed out |
1572 ms |
1388 KB |
Time limit exceeded |
36 |
Execution timed out |
1571 ms |
1388 KB |
Time limit exceeded |
37 |
Execution timed out |
1546 ms |
1032 KB |
Time limit exceeded |
38 |
Execution timed out |
1581 ms |
1388 KB |
Time limit exceeded |
39 |
Execution timed out |
1545 ms |
668 KB |
Time limit exceeded |
40 |
Execution timed out |
1557 ms |
620 KB |
Time limit exceeded |
41 |
Execution timed out |
1564 ms |
876 KB |
Time limit exceeded |
42 |
Execution timed out |
1579 ms |
744 KB |
Time limit exceeded |
43 |
Execution timed out |
1571 ms |
876 KB |
Time limit exceeded |
44 |
Execution timed out |
1570 ms |
1516 KB |
Time limit exceeded |
45 |
Execution timed out |
1543 ms |
1004 KB |
Time limit exceeded |
46 |
Execution timed out |
1578 ms |
1772 KB |
Time limit exceeded |
47 |
Execution timed out |
1554 ms |
1644 KB |
Time limit exceeded |
48 |
Execution timed out |
1590 ms |
1516 KB |
Time limit exceeded |
49 |
Execution timed out |
1575 ms |
1804 KB |
Time limit exceeded |
50 |
Execution timed out |
1597 ms |
620 KB |
Time limit exceeded |