Submission #8399895
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> Pii; typedef pair<ll,ll> Pll; #define rep(i,n) for (ll i=0;i<n;++i) #define rep2(i,a,b) for (ll i=a;i<b;++i) const ll MOD=1e9+7; const ll INF=1e9; const ll IINF=1e18; const double EPS=1e-8; const double pi=acos(-1); template<class T> inline bool chmin(T &a,T b){ if (a>b){ a=b; return true; } return false; } template<class T> inline bool chmax(T &a,T b){ if (a<b){ a=b; return true; } return false; } int main(){ int N,M,Q; cin >> N >> M >> Q; vector<string> S(N); rep(i,N) cin >> S[i]; vector<vector<int>> blue(N+1,vector<int>(M+1,0)); rep(i,N) rep(j,M) if (S[i][j]=='1') ++blue[i+1][j+1]; rep(i,N+1) rep(j,M) blue[i][j+1]+=blue[i][j]; rep(j,M+1) rep(i,N) blue[i+1][j]+=blue[i][j]; vector<vector<int>> eh(N+1,vector<int>(M,0)),ew(N,vector<int>(M+1,0)); rep(i,N) rep(j,M-1) if (S[i][j]=='1'&&S[i][j+1]=='1') ++eh[i+1][j+1]; rep(i,N+1) rep(j,M-1) eh[i][j+1]+=eh[i][j]; rep(j,M) rep(i,N) eh[i+1][j]+=eh[i][j]; rep(j,M) rep(i,N-1) if (S[i][j]=='1'&&S[i+1][j]=='1') ++ew[i+1][j+1]; rep(j,M+1) rep(i,N-1) ew[i+1][j]+=ew[i][j]; rep(i,N) rep(j,M) ew[i][j+1]+=ew[i][j]; rep(i,Q){ int a,b,c,d; cin >> a >> b >> c >> d; int node=blue[c][d]-blue[c][b-1]-blue[a-1][d]+blue[a-1][b-1]; int edge=eh[c][d-1]-eh[a-1][d-1]-eh[c][b-1]+eh[a-1][b-1]; edge+=ew[c-1][d]-ew[a-1][d]-ew[c-1][b-1]+ew[a-1][b-1]; cout << node-edge << endl; } }
Submission Info
Submission Time | |
---|---|
Task | C - Nuske vs Phantom Thnook |
User | rniya |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1633 Byte |
Status | AC |
Exec Time | 1043 ms |
Memory | 52992 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 700 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, s1.txt, s2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 983 ms | 52608 KB |
02.txt | AC | 1036 ms | 52608 KB |
03.txt | AC | 1003 ms | 52608 KB |
04.txt | AC | 1040 ms | 52224 KB |
05.txt | AC | 996 ms | 52864 KB |
06.txt | AC | 1040 ms | 52480 KB |
07.txt | AC | 875 ms | 50176 KB |
08.txt | AC | 939 ms | 50432 KB |
09.txt | AC | 916 ms | 47616 KB |
10.txt | AC | 1042 ms | 52480 KB |
11.txt | AC | 974 ms | 52608 KB |
12.txt | AC | 712 ms | 20352 KB |
13.txt | AC | 485 ms | 1664 KB |
14.txt | AC | 489 ms | 1152 KB |
15.txt | AC | 447 ms | 640 KB |
16.txt | AC | 487 ms | 1024 KB |
17.txt | AC | 485 ms | 1408 KB |
18.txt | AC | 515 ms | 1024 KB |
19.txt | AC | 480 ms | 1024 KB |
20.txt | AC | 899 ms | 46720 KB |
21.txt | AC | 928 ms | 52096 KB |
22.txt | AC | 1043 ms | 52480 KB |
23.txt | AC | 498 ms | 1536 KB |
24.txt | AC | 1030 ms | 52480 KB |
25.txt | AC | 458 ms | 640 KB |
26.txt | AC | 475 ms | 896 KB |
27.txt | AC | 483 ms | 896 KB |
28.txt | AC | 485 ms | 1024 KB |
29.txt | AC | 482 ms | 1408 KB |
30.txt | AC | 485 ms | 1024 KB |
31.txt | AC | 897 ms | 52992 KB |
32.txt | AC | 964 ms | 52736 KB |
33.txt | AC | 938 ms | 52480 KB |
34.txt | AC | 958 ms | 52736 KB |
35.txt | AC | 903 ms | 52224 KB |
36.txt | AC | 985 ms | 52224 KB |
37.txt | AC | 899 ms | 52224 KB |
38.txt | AC | 989 ms | 52224 KB |
39.txt | AC | 898 ms | 52864 KB |
40.txt | AC | 952 ms | 52736 KB |
41.txt | AC | 933 ms | 52480 KB |
42.txt | AC | 983 ms | 52224 KB |
43.txt | AC | 898 ms | 51840 KB |
44.txt | AC | 982 ms | 52096 KB |
45.txt | AC | 1 ms | 256 KB |
46.txt | AC | 1 ms | 256 KB |
47.txt | AC | 1 ms | 256 KB |
48.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |