hiho week 234 register

Ended

Participants:94

Verdict:Accepted
Score:100 / 100
Submitted:2018-12-22 20:06:04

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,m,i,N,x[20],y[20];
ll ans;
void dfs(int s,int lx,int ly,int rx,int ry,int d)
{
    if(s==N)
    {
        if(!d)ans+=(ll)n*(n+1)/2*m*(m+1)/2;
        else if(d&1)ans-=(ll)lx*(n+1-rx)*ly*(n+1-ry);
        else ans+=(ll)lx*(n+1-rx)*ly*(n+1-ry);
        return;
    }
    dfs(s+1,lx,ly,rx,ry,d);
    dfs(s+1,min(lx,x[s]),min(ly,y[s]),max(rx,x[s]),max(ry,y[s]),d+1);
}
int main()
{
    cin>>n>>m>>N;
    for(i=0;i<N;i++)cin>>x[i]>>y[i];
    dfs(0,n+1,m+1,0,0,0);
    cout<<ans<<endl;
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX