// ItnoE
#include<bits/stdc++.h>
#define lc (id << 1)
#define rc (lc ^ 1)
#define md (l + r >> 1)
using namespace std;
int R, ts, ret[11];
struct Tree
{
int N, * MX;
inline Tree(int _N = 0)
{
N = _N;
MX = new int [N + 3 << 1];
}
inline void Setter(int i, int val)
{
Set(i, val, 1, 1, N + 1);
}
inline void Getter(int val, int d)
{
ts = 0;
if (d == 0)
GetPref(val, 1, 1, N + 1);
else
GetSuff(val, 1, 1, N + 1);
}
void Set(int i, int val, int id, int l, int r)
{
if (r - l < 2)
return void(MX[id] = val);
if (i < md)
Set(i, val, lc, l, md);
else
Set(i, val, rc, md, r);
MX[id] = max(MX[lc], MX[rc]);
}
void GetPref(int val, int id, int l, int r)
{
if (MX[id] < val || ts >= R)
return ;
if (r - l < 2)
return void(ret[ts ++] = l);
GetPref(val, lc, l, md);
GetPref(val, rc, md, r);
}
void GetSuff(int val, int id, int l, int r)
{
if (MX[id] < val || ts >= R)
return ;
if (r - l < 2)
return void(ret[ts ++] = l);
GetSuff(val, rc, md, r);
GetSuff(val, lc, l, md);
}
};
int main()
{
int n, m, q, p;
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m >> R >> q >> p;
int A[n + 3][m + 3];
memset(A, 0, sizeof(A));
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= m; j ++)
cin >> A[i][j];
Tree rows[n + 3], cols[m + 3];
for (int i = 1; i <= n; i ++)
rows[i] = Tree(m);
for (int i = 1; i <= m; i ++)
cols[i] = Tree(n);
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= m; j ++)
{
rows[i].Setter(j, A[i][j]);
cols[j].Setter(i, A[i][j]);
}
for (; q; q --)
{
char ch;
int id, h;
cin >> ch >> id >> h;
if (ch == 'W' || ch == 'E')
{
rows[id].Getter(h, ch == 'E');
for (int i = 0; i < ts; i ++)
{
A[id][ret[i]] --;
rows[id].Setter(ret[i], A[id][ret[i]]);
cols[ret[i]].Setter(id, A[id][ret[i]]);
}
}
else
{
cols[id].Getter(h, ch == 'S');
for (int i = 0; i < ts; i ++)
{
A[ret[i]][id] --;
rows[ret[i]].Setter(id, A[ret[i]][id]);
cols[id].Setter(ret[i], A[ret[i]][id]);
}
}
}
int Mx = 0;
for (int i = p; i <= n; i ++)
for (int j = p; j <= m; j ++)
{
int SM = 0;
for (int a = i - p + 1; a <= i; a ++)
for (int b = j - p + 1; b <= j; b ++)
SM += A[a][b];
Mx = max(Mx, SM);
}
return !printf("%d\n", Mx);
}
Compilation message
ufo.cpp: In constructor 'Tree::Tree(int)':
ufo.cpp:14:25: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
MX = new int [N + 3 << 1];
~~^~~
ufo.cpp: In member function 'void Tree::Set(int, int, int, int, int)':
ufo.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
#define md (l + r >> 1)
~~^~~
ufo.cpp:32:17: note: in expansion of macro 'md'
if (i < md)
^~
ufo.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
#define md (l + r >> 1)
~~^~~
ufo.cpp:33:32: note: in expansion of macro 'md'
Set(i, val, lc, l, md);
^~
ufo.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
#define md (l + r >> 1)
~~^~~
ufo.cpp:35:29: note: in expansion of macro 'md'
Set(i, val, rc, md, r);
^~
ufo.cpp: In member function 'void Tree::GetPref(int, int, int, int)':
ufo.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
#define md (l + r >> 1)
~~^~~
ufo.cpp:44:29: note: in expansion of macro 'md'
GetPref(val, lc, l, md);
^~
ufo.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
#define md (l + r >> 1)
~~^~~
ufo.cpp:45:26: note: in expansion of macro 'md'
GetPref(val, rc, md, r);
^~
ufo.cpp: In member function 'void Tree::GetSuff(int, int, int, int)':
ufo.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
#define md (l + r >> 1)
~~^~~
ufo.cpp:53:26: note: in expansion of macro 'md'
GetSuff(val, rc, md, r);
^~
ufo.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
#define md (l + r >> 1)
~~^~~
ufo.cpp:54:29: note: in expansion of macro 'md'
GetSuff(val, lc, l, md);
^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
4 |
Incorrect |
17 ms |
632 KB |
Output isn't correct |
5 |
Correct |
81 ms |
2424 KB |
Output is correct |
6 |
Incorrect |
229 ms |
13304 KB |
Output isn't correct |
7 |
Runtime error |
167 ms |
49476 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
126 ms |
45916 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
108 ms |
36216 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
127 ms |
45932 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Runtime error |
131 ms |
49016 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Runtime error |
125 ms |
45944 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Runtime error |
202 ms |
56356 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Runtime error |
134 ms |
49144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Runtime error |
136 ms |
46828 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
16 |
Runtime error |
132 ms |
49196 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
17 |
Runtime error |
249 ms |
59768 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
18 |
Runtime error |
202 ms |
58596 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Runtime error |
163 ms |
68344 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
20 |
Runtime error |
504 ms |
238184 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |