Submission #1990401
Source Code Expand
#include "bits/stdc++.h"
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;
const int MAX_N = 2003;
int a[MAX_N][MAX_N],node[MAX_N][MAX_N],edgex[MAX_N][MAX_N],edgey[MAX_N][MAX_N];
string S[MAX_N];
int main(){
int N,M,Q; cin >> N >> M >> Q ;
fill(node[0],node[MAX_N-1],0);
fill(edgex[0],edgex[MAX_N-1],0);
fill(edgey[0],edgey[MAX_N-1],0);
rep(i,N) cin >> S[i];
rep(i,N) rep(j,M) a[i+1][j+1] = int(S[i][j]=='1');
REP(i,1,N+1) REP(j,1,M+1) node[i][j] = a[i][j] + node[i-1][j] + node[i][j-1] - node[i-1][j-1];
REP(i,1,N+1) REP(j,1,M+1){
edgex[i][j] = (a[i][j]&a[i-1][j]) + edgex[i-1][j] + edgex[i][j-1] - edgex[i-1][j-1];
edgey[i][j] = (a[i][j]&a[i][j-1]) + edgey[i-1][j] + edgey[i][j-1] - edgey[i-1][j-1];
}
// rep(i,N+1){
// rep(j,M+1) cout << edge[i][j] << " ";
// cout << "" << endl;
// }
rep(i,Q){
int x1,y1,x2,y2;
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
int n = node[x2][y2] - node[x1-1][y2] - node[x2][y1-1] + node[x1-1][y1-1];
int ex = edgex[x2][y2] - edgex[x1][y2] - edgex[x2][y1-1] + edgex[x1][y1-1];
int ey = edgey[x2][y2] - edgey[x1-1][y2] - edgey[x2][y1] + edgey[x1-1][y1];
// cout << n << " "<< ex << " " << ey << endl;
cout << n - (ex + ey) << endl;
}
return 0;
}
Submission Info
Submission Time
2018-01-18 23:13:57+0900
Task
C - Nuske vs Phantom Thnook
User
kurarrr
Language
C++14 (GCC 5.4.1)
Score
700
Code Size
1611 Byte
Status
AC
Exec Time
630 ms
Memory
68608 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:41:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
^
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
569 ms
68224 KB
02.txt
AC
597 ms
68096 KB
03.txt
AC
584 ms
68224 KB
04.txt
AC
601 ms
67968 KB
05.txt
AC
579 ms
68352 KB
06.txt
AC
606 ms
68096 KB
07.txt
AC
557 ms
67968 KB
08.txt
AC
630 ms
67328 KB
09.txt
AC
559 ms
67456 KB
10.txt
AC
597 ms
67968 KB
11.txt
AC
574 ms
68224 KB
12.txt
AC
498 ms
60672 KB
13.txt
AC
413 ms
63232 KB
14.txt
AC
417 ms
50176 KB
15.txt
AC
405 ms
47744 KB
16.txt
AC
412 ms
48000 KB
17.txt
AC
418 ms
63232 KB
18.txt
AC
412 ms
62848 KB
19.txt
AC
401 ms
48128 KB
20.txt
AC
574 ms
65792 KB
21.txt
AC
575 ms
67584 KB
22.txt
AC
595 ms
67968 KB
23.txt
AC
411 ms
50176 KB
24.txt
AC
598 ms
67968 KB
25.txt
AC
406 ms
47744 KB
26.txt
AC
423 ms
49920 KB
27.txt
AC
397 ms
47872 KB
28.txt
AC
414 ms
62848 KB
29.txt
AC
408 ms
63232 KB
30.txt
AC
409 ms
48000 KB
31.txt
AC
569 ms
68608 KB
32.txt
AC
599 ms
68352 KB
33.txt
AC
569 ms
67968 KB
34.txt
AC
604 ms
68224 KB
35.txt
AC
566 ms
67840 KB
36.txt
AC
595 ms
67712 KB
37.txt
AC
566 ms
67840 KB
38.txt
AC
597 ms
67712 KB
39.txt
AC
571 ms
68352 KB
40.txt
AC
598 ms
68224 KB
41.txt
AC
574 ms
67968 KB
42.txt
AC
596 ms
67840 KB
43.txt
AC
570 ms
67456 KB
44.txt
AC
596 ms
67584 KB
45.txt
AC
15 ms
47360 KB
46.txt
AC
15 ms
47360 KB
47.txt
AC
15 ms
47360 KB
48.txt
AC
15 ms
47360 KB
s1.txt
AC
15 ms
47360 KB
s2.txt
AC
16 ms
47360 KB