Submission #2229322
Source Code Expand
#include <bits/stdc++.h> #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i,n) for(int i=0;i<(int)(n);++i) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i) #define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i) #define each(a,b) for(auto& (a): (b)) #define all(v) (v).begin(),(v).end() #define len(v) (int)(v).size() #define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) #define cmx(x,y) x=max(x,y) #define cmn(x,y) x=min(x,y) #define fi first #define se second #define pb push_back #define show(x) cout<<#x<<" = "<<(x)<<endl #define spair(p) cout<<#p<<": "<<p.fi<" "<<p.se<<endl #define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl #define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl #define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl #define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl #define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl using namespace std; typedef pair<int,int> P; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<double> vd; typedef vector<P> vp; typedef vector<string> vs; const int MAX_N = 4005; int num[MAX_N][MAX_N]; int sm[MAX_N][MAX_N]; int main() { cin.tie(0); ios::sync_with_stdio(false); int n,m,q; cin >> n >> m >> q; vs s(n); rep(i,n){ cin >> s[i]; } rep(i,n){ rep(j,m){ num[2*i][2*j] = (s[i][j] -'0'); } } rep(i,n){ rep(j,m-1){ if(s[i][j] == '1' && s[i][j+1] == '1'){ num[2*i][2*j+1] = -1; } } } rep(j,m){ rep(i,n-1){ if(s[i][j] == '1' && s[i+1][j] == '1'){ num[2*i+1][2*j] = -1; } } } rep(i,2*n){ rep(j,2*m){ sm[i+1][j+1] = sm[i+1][j] + num[i][j]; } } rep(j,2*m+1){ rep(i,2*n+1){ sm[i+1][j] += sm[i][j]; } } rep(i,q){ int a,b,c,d; cin >> a >> b >> c >> d; --a,--b,--c,--d; cout << sm[2*c+1][2*d+1] - sm[2*a][2*d+1] - sm[2*c+1][2*b] + sm[2*a][2*b] << "\n"; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Nuske vs Phantom Thnook |
User | kopricky |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 2211 Byte |
Status | AC |
Exec Time | 276 ms |
Memory | 131200 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 | 256 ms | 130944 KB |
02.txt | AC | 276 ms | 130816 KB |
03.txt | AC | 253 ms | 130816 KB |
04.txt | AC | 271 ms | 130688 KB |
05.txt | AC | 261 ms | 131072 KB |
06.txt | AC | 276 ms | 130816 KB |
07.txt | AC | 203 ms | 130304 KB |
08.txt | AC | 228 ms | 128256 KB |
09.txt | AC | 230 ms | 127872 KB |
10.txt | AC | 272 ms | 130688 KB |
11.txt | AC | 254 ms | 130944 KB |
12.txt | AC | 140 ms | 74112 KB |
13.txt | AC | 93 ms | 124672 KB |
14.txt | AC | 70 ms | 3328 KB |
15.txt | AC | 62 ms | 2688 KB |
16.txt | AC | 70 ms | 3072 KB |
17.txt | AC | 92 ms | 124672 KB |
18.txt | AC | 93 ms | 124288 KB |
19.txt | AC | 67 ms | 3200 KB |
20.txt | AC | 212 ms | 121216 KB |
21.txt | AC | 209 ms | 130176 KB |
22.txt | AC | 272 ms | 130688 KB |
23.txt | AC | 75 ms | 16128 KB |
24.txt | AC | 273 ms | 130688 KB |
25.txt | AC | 63 ms | 2688 KB |
26.txt | AC | 69 ms | 9600 KB |
27.txt | AC | 67 ms | 2944 KB |
28.txt | AC | 93 ms | 124288 KB |
29.txt | AC | 92 ms | 124672 KB |
30.txt | AC | 70 ms | 3072 KB |
31.txt | AC | 212 ms | 131200 KB |
32.txt | AC | 231 ms | 130944 KB |
33.txt | AC | 214 ms | 130688 KB |
34.txt | AC | 235 ms | 130816 KB |
35.txt | AC | 211 ms | 130432 KB |
36.txt | AC | 235 ms | 130432 KB |
37.txt | AC | 211 ms | 130432 KB |
38.txt | AC | 235 ms | 130432 KB |
39.txt | AC | 211 ms | 130944 KB |
40.txt | AC | 230 ms | 130816 KB |
41.txt | AC | 215 ms | 130688 KB |
42.txt | AC | 231 ms | 130560 KB |
43.txt | AC | 210 ms | 130048 KB |
44.txt | AC | 235 ms | 130304 KB |
45.txt | AC | 1 ms | 2304 KB |
46.txt | AC | 1 ms | 2304 KB |
47.txt | AC | 1 ms | 2304 KB |
48.txt | AC | 1 ms | 2304 KB |
s1.txt | AC | 1 ms | 2304 KB |
s2.txt | AC | 2 ms | 2304 KB |