Submission #1612314


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,b,a) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<#x" = "<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nex)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int rd() {
	int x=0,c=0,f=1;
	for(; c<'0'||c>'9'; c=getchar())f=c!='-';
	for(; c>='0'&&c<='9'; c=getchar())x=x*10+c-'0';
	return f?x:-x;
}
const int N=2100;
char G[N][N];
int t[N][N],a[N][N],b[N][N],c[N][N];
int F(int x,int y,int z,int w){
	return (a[z][w]-a[x-1][w]-a[z][y-1]+a[x-1][y-1])-(b[z][w]-b[x-1][w]-b[z][y]+b[x-1][y])-(c[z][w]-c[x][w]-c[z][y-1]+c[x][y-1]);
}
int main() {
	int n = rd(), m = rd(), T = rd();
	rep(i,1,n)scanf("%s",G[i]+1);
	rep(i,1,n)rep(j,1,m){
		t[i][j] = G[i][j] - '0';
	}
	rep(i,1,n)rep(j,1,m){
		a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+t[i][j];
	}
	rep(i,1,n)rep(j,2,m){
		b[i][j]=b[i-1][j]+b[i][j-1]-b[i-1][j-1]+(t[i][j-1]&t[i][j]);
	}
	rep(i,2,n)rep(j,1,m){
		c[i][j]=c[i-1][j]+c[i][j-1]-c[i-1][j-1]+(t[i-1][j]&t[i][j]);
	}
	
	while(T--) {
		int a = rd(), b = rd(), c = rd(), d = rd();
		printf("%d\n",F(a,b,c,d));
	}
}

Submission Info

Submission Time
Task C - Nuske vs Phantom Thnook
User flukehn
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1480 Byte
Status AC
Exec Time 135 ms
Memory 74752 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:31:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  rep(i,1,n)scanf("%s",G[i]+1);
                              ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 2
AC × 50
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 109 ms 74368 KB
02.txt AC 132 ms 74240 KB
03.txt AC 109 ms 74368 KB
04.txt AC 134 ms 74240 KB
05.txt AC 109 ms 74624 KB
06.txt AC 132 ms 74240 KB
07.txt AC 106 ms 74240 KB
08.txt AC 130 ms 74112 KB
09.txt AC 102 ms 74240 KB
10.txt AC 131 ms 74240 KB
11.txt AC 109 ms 74368 KB
12.txt AC 81 ms 48256 KB
13.txt AC 53 ms 72960 KB
14.txt AC 43 ms 9216 KB
15.txt AC 34 ms 6784 KB
16.txt AC 42 ms 9088 KB
17.txt AC 52 ms 72960 KB
18.txt AC 51 ms 58240 KB
19.txt AC 39 ms 9216 KB
20.txt AC 124 ms 73216 KB
21.txt AC 107 ms 73856 KB
22.txt AC 132 ms 74240 KB
23.txt AC 47 ms 16256 KB
24.txt AC 132 ms 74240 KB
25.txt AC 31 ms 8832 KB
26.txt AC 41 ms 11520 KB
27.txt AC 38 ms 8960 KB
28.txt AC 51 ms 58240 KB
29.txt AC 52 ms 72960 KB
30.txt AC 42 ms 9088 KB
31.txt AC 110 ms 74752 KB
32.txt AC 133 ms 74496 KB
33.txt AC 108 ms 74240 KB
34.txt AC 135 ms 74496 KB
35.txt AC 113 ms 73984 KB
36.txt AC 130 ms 73984 KB
37.txt AC 108 ms 73984 KB
38.txt AC 130 ms 73984 KB
39.txt AC 109 ms 74624 KB
40.txt AC 135 ms 74496 KB
41.txt AC 108 ms 74240 KB
42.txt AC 130 ms 73984 KB
43.txt AC 109 ms 73600 KB
44.txt AC 130 ms 73856 KB
45.txt AC 2 ms 6400 KB
46.txt AC 2 ms 8448 KB
47.txt AC 2 ms 8448 KB
48.txt AC 3 ms 8448 KB
s1.txt AC 2 ms 8448 KB
s2.txt AC 2 ms 8448 KB