#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #include #include #include #include // clang-format off #define RD(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} #define WT(var,buf,ptr) long v=var;ptr=0;while(v){buf[ptr++]=v%10;v/=10;}while(ptr--){*wp++=buf[ptr]+'0';}*wp++='\n'; // clang-format on int y[100000]; int x[100000]; char wbuf[100000 * 21]; int main() { char *rp = (char *)mmap(0l, 1l << 28, 1, 2, 0, 0ll); char *wp = wbuf; RD(h) RD(w) RD(q); int *xp = x, *yp = y; for (int i = 0; i < q; ++i) { RD(yy) RD(xx); *yp++ = --yy; *xp++ = --xx; } std::map mp; xp = x, yp = y; long prod = (long)h * w; char buf[9]; int ptr; for (int i = 0; i < q; ++i) { int mi = (mp.count(*xp)) ? mp[*xp] : h; // if (*yp < mi) { prod -= (mi - *yp); mp[*xp] = *yp; } xp++, yp++; // WT(prod, buf, ptr); } write(1, wbuf, (wp - wbuf) * sizeof(*wbuf)); exit(0); return 0; }