# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
53966 |
2018-07-02T05:55:41 Z |
김세빈(#1455) |
Pyramid Base (IOI08_pyramid_base) |
C++11 |
|
5000 ms |
77716 KB |
#include <bits/stdc++.h>
using namespace std;
int T[2202020], L[2202020];
vector <int> V[1010101];
int X1[404040], X2[404040], Y1[404040], Y2[404040], C[404040];
int n, m, c, k, sz;
void add(int p, int s, int e, int l, int r, int v)
{
if(r < s || e < l) return;
if(l <= s && e <= r){
L[p] += v;
return;
}
L[p<<1] += L[p], L[p<<1|1] += L[p];
L[p] = 0;
add(p<<1, s, s+e>>1, l, r, v);
add(p<<1|1, (s+e>>1)+1, e, l, r, v);
T[p] = min(T[p<<1] + L[p<<1], T[p<<1|1] + L[p<<1|1]);
}
bool check(int t)
{
int i, j, p;
for(i=1;i<=n-t+1;i++) V[i].clear();
for(i=1;i<sz+sz;i++) T[i] = L[i] = 0;
for(i=1;i<=k;i++){
V[max(1, X1[i]-t+1)].push_back(i);
V[min(n-t+1, X2[i])+1].push_back(-i);
}
for(i=1;i<=n-t+1;i++){
for(j=0;j<V[i].size();j++){
p = V[i][j];
if(p > 0) add(1, 1, m-t+1, Y1[p]-t+1, Y2[p], 1);
else add(1, 1, m-t+1, Y1[-p]-t+1, Y2[-p], -1);
}
// printf("%d %d\n",i,T[1]+L[1]);
if(T[1] + L[1] == 0) return 1;
}
return 0;
}
int main()
{
// freopen("input.txt", "r", stdin);
int i, s, e;
scanf("%d%d%d%d", &n, &m, &c, &k);
for(sz=1;sz<=n && sz<=m;sz<<=1);
for(i=1;i<=k;i++){
scanf("%d%d%d%d%d", X1+i, Y1+i, X2+i, Y2+i, C+i);
}
for(s=1,e=min(n,m); s<=e;){
if(check(s+e>>1)) s = (s+e>>1) + 1;
else e = (s+e>>1) - 1;
}
printf("%d\n", s-1);
return 0;
}
Compilation message
pyramid_base.cpp: In function 'void add(int, int, int, int, int, int)':
pyramid_base.cpp:21:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
add(p<<1, s, s+e>>1, l, r, v);
~^~
pyramid_base.cpp:22:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
add(p<<1|1, (s+e>>1)+1, e, l, r, v);
~^~
pyramid_base.cpp: In function 'bool check(int)':
pyramid_base.cpp:40:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(j=0;j<V[i].size();j++){
~^~~~~~~~~~~~
pyramid_base.cpp: In function 'int main()':
pyramid_base.cpp:69:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
if(check(s+e>>1)) s = (s+e>>1) + 1;
~^~
pyramid_base.cpp:69:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
if(check(s+e>>1)) s = (s+e>>1) + 1;
~^~
pyramid_base.cpp:70:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
else e = (s+e>>1) - 1;
~^~
pyramid_base.cpp:60:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d%d", &n, &m, &c, &k);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
pyramid_base.cpp:65:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d%d%d", X1+i, Y1+i, X2+i, Y2+i, C+i);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
24056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
24168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
24376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
24708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
26788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
166 ms |
41264 KB |
Output is correct |
2 |
Correct |
330 ms |
41464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
346 ms |
41552 KB |
Output is correct |
2 |
Correct |
212 ms |
41552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
98 ms |
41552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
357 ms |
41552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1194 ms |
51996 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1304 ms |
54236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1711 ms |
56204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5028 ms |
73332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5007 ms |
76032 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5019 ms |
77716 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |