# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
145437 |
2019-08-19T21:01:55 Z |
MvC |
Rectangles (IOI19_rect) |
C++14 |
|
2271 ms |
76940 KB |
#include "rect.h"
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=7e2+5;
const int mod=1e9+7;
using namespace std;
int n,m,a[nmax][nmax],i,j,t,x,y,rs;
vector<pair<int,int> >pr[nmax];
vector<int>vc[nmax][nmax],st;
bitset<nmax>bs,b[nmax][nmax];
ll count_rectangles(vector<vector<int> > A)
{
n=A.size(),m=A[0].size();
for(i=1;i<=n;i++)for(j=1;j<=m;j++)a[i][j]=A[i-1][j-1];
for(i=1;i<=n;i++)
{
st.clear();
for(j=1;j<=m;j++)
{
while(!st.empty() && a[i][st.back()]<a[i][j])
{
if(st.back()+1<j)
{
pr[i].pb(mkp(st.back(),j));
vc[st.back()][j].pb(i);
}
st.pop_back();
}
if(!st.empty() && st.back()+1<j)
{
pr[i].pb(mkp(st.back(),j));
vc[st.back()][j].pb(i);
}
while(!st.empty() && a[i][st.back()]==a[i][j])st.pop_back();
st.pb(j);
}
}
for(i=1;i<=m;i++)
{
st.clear();
for(j=n;j>=1;j--)
{
while(!st.empty() && a[st.back()][i]<a[j][i])
{
if(st.back()>j+1)b[j][i][st.back()]=1;
st.pop_back();
}
if(!st.empty() && st.back()>j+1)b[j][i][st.back()]=1;
while(!st.empty() && a[st.back()][i]==a[j][i])st.pop_back();
st.pb(j);
}
}
for(i=1;i<=n;i++)
{
for(j=0;j<pr[i].size();j++)
{
x=pr[i][j].fr,y=pr[i][j].sc;
bs.set();
for(t=x+1;t<=y-1;t++)
{
bs&=b[i-1][t];
}
for(t=0;t<vc[x][y].size();t++)if(vc[x][y][t]==i)break;
for(;t<vc[x][y].size();t++)
{
if(vc[x][y][t]!=i && vc[x][y][t]!=vc[x][y][t-1]+1)break;
rs+=bs[vc[x][y][t]+1];
}
}
}
return rs;
}
Compilation message
rect.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization("O3")
rect.cpp:4:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization("unroll-loops")
rect.cpp: In function 'll count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:71:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(j=0;j<pr[i].size();j++)
~^~~~~~~~~~~~~
rect.cpp:79:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(t=0;t<vc[x][y].size();t++)if(vc[x][y][t]==i)break;
~^~~~~~~~~~~~~~~~
rect.cpp:80:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(;t<vc[x][y].size();t++)
~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
12024 KB |
Output is correct |
2 |
Correct |
15 ms |
12280 KB |
Output is correct |
3 |
Correct |
13 ms |
12280 KB |
Output is correct |
4 |
Correct |
16 ms |
12280 KB |
Output is correct |
5 |
Correct |
16 ms |
12152 KB |
Output is correct |
6 |
Correct |
15 ms |
12280 KB |
Output is correct |
7 |
Correct |
15 ms |
12280 KB |
Output is correct |
8 |
Correct |
13 ms |
12152 KB |
Output is correct |
9 |
Correct |
15 ms |
12280 KB |
Output is correct |
10 |
Correct |
13 ms |
12280 KB |
Output is correct |
11 |
Correct |
13 ms |
12280 KB |
Output is correct |
12 |
Correct |
13 ms |
12280 KB |
Output is correct |
13 |
Correct |
12 ms |
12024 KB |
Output is correct |
14 |
Correct |
13 ms |
12056 KB |
Output is correct |
15 |
Correct |
12 ms |
12024 KB |
Output is correct |
16 |
Correct |
12 ms |
12024 KB |
Output is correct |
17 |
Correct |
13 ms |
12024 KB |
Output is correct |
18 |
Correct |
12 ms |
12024 KB |
Output is correct |
19 |
Correct |
16 ms |
12280 KB |
Output is correct |
20 |
Correct |
15 ms |
12152 KB |
Output is correct |
21 |
Correct |
14 ms |
12024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
12024 KB |
Output is correct |
2 |
Correct |
15 ms |
12280 KB |
Output is correct |
3 |
Correct |
13 ms |
12280 KB |
Output is correct |
4 |
Correct |
16 ms |
12280 KB |
Output is correct |
5 |
Correct |
16 ms |
12152 KB |
Output is correct |
6 |
Correct |
15 ms |
12280 KB |
Output is correct |
7 |
Correct |
15 ms |
12280 KB |
Output is correct |
8 |
Correct |
13 ms |
12152 KB |
Output is correct |
9 |
Correct |
15 ms |
12280 KB |
Output is correct |
10 |
Correct |
13 ms |
12280 KB |
Output is correct |
11 |
Correct |
13 ms |
12280 KB |
Output is correct |
12 |
Correct |
13 ms |
12280 KB |
Output is correct |
13 |
Correct |
12 ms |
12024 KB |
Output is correct |
14 |
Correct |
13 ms |
12056 KB |
Output is correct |
15 |
Correct |
12 ms |
12024 KB |
Output is correct |
16 |
Correct |
12 ms |
12024 KB |
Output is correct |
17 |
Correct |
17 ms |
13304 KB |
Output is correct |
18 |
Correct |
21 ms |
13304 KB |
Output is correct |
19 |
Correct |
20 ms |
13304 KB |
Output is correct |
20 |
Correct |
17 ms |
13176 KB |
Output is correct |
21 |
Correct |
18 ms |
13304 KB |
Output is correct |
22 |
Correct |
16 ms |
13304 KB |
Output is correct |
23 |
Correct |
16 ms |
13304 KB |
Output is correct |
24 |
Correct |
17 ms |
12920 KB |
Output is correct |
25 |
Correct |
13 ms |
12024 KB |
Output is correct |
26 |
Correct |
12 ms |
12024 KB |
Output is correct |
27 |
Correct |
16 ms |
12280 KB |
Output is correct |
28 |
Correct |
15 ms |
12152 KB |
Output is correct |
29 |
Correct |
14 ms |
12024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
12024 KB |
Output is correct |
2 |
Correct |
15 ms |
12280 KB |
Output is correct |
3 |
Correct |
13 ms |
12280 KB |
Output is correct |
4 |
Correct |
16 ms |
12280 KB |
Output is correct |
5 |
Correct |
16 ms |
12152 KB |
Output is correct |
6 |
Correct |
15 ms |
12280 KB |
Output is correct |
7 |
Correct |
15 ms |
12280 KB |
Output is correct |
8 |
Correct |
13 ms |
12152 KB |
Output is correct |
9 |
Correct |
15 ms |
12280 KB |
Output is correct |
10 |
Correct |
13 ms |
12280 KB |
Output is correct |
11 |
Correct |
13 ms |
12280 KB |
Output is correct |
12 |
Correct |
13 ms |
12280 KB |
Output is correct |
13 |
Correct |
12 ms |
12024 KB |
Output is correct |
14 |
Correct |
13 ms |
12056 KB |
Output is correct |
15 |
Correct |
12 ms |
12024 KB |
Output is correct |
16 |
Correct |
12 ms |
12024 KB |
Output is correct |
17 |
Correct |
17 ms |
13304 KB |
Output is correct |
18 |
Correct |
21 ms |
13304 KB |
Output is correct |
19 |
Correct |
20 ms |
13304 KB |
Output is correct |
20 |
Correct |
17 ms |
13176 KB |
Output is correct |
21 |
Correct |
18 ms |
13304 KB |
Output is correct |
22 |
Correct |
16 ms |
13304 KB |
Output is correct |
23 |
Correct |
16 ms |
13304 KB |
Output is correct |
24 |
Correct |
17 ms |
12920 KB |
Output is correct |
25 |
Correct |
71 ms |
18340 KB |
Output is correct |
26 |
Correct |
69 ms |
18296 KB |
Output is correct |
27 |
Correct |
76 ms |
18296 KB |
Output is correct |
28 |
Correct |
24 ms |
17772 KB |
Output is correct |
29 |
Correct |
31 ms |
18296 KB |
Output is correct |
30 |
Correct |
29 ms |
18424 KB |
Output is correct |
31 |
Correct |
28 ms |
18248 KB |
Output is correct |
32 |
Correct |
28 ms |
18212 KB |
Output is correct |
33 |
Correct |
13 ms |
12024 KB |
Output is correct |
34 |
Correct |
12 ms |
12024 KB |
Output is correct |
35 |
Correct |
16 ms |
12280 KB |
Output is correct |
36 |
Correct |
15 ms |
12152 KB |
Output is correct |
37 |
Correct |
14 ms |
12024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
12024 KB |
Output is correct |
2 |
Correct |
15 ms |
12280 KB |
Output is correct |
3 |
Correct |
13 ms |
12280 KB |
Output is correct |
4 |
Correct |
16 ms |
12280 KB |
Output is correct |
5 |
Correct |
16 ms |
12152 KB |
Output is correct |
6 |
Correct |
15 ms |
12280 KB |
Output is correct |
7 |
Correct |
15 ms |
12280 KB |
Output is correct |
8 |
Correct |
13 ms |
12152 KB |
Output is correct |
9 |
Correct |
15 ms |
12280 KB |
Output is correct |
10 |
Correct |
13 ms |
12280 KB |
Output is correct |
11 |
Correct |
13 ms |
12280 KB |
Output is correct |
12 |
Correct |
13 ms |
12280 KB |
Output is correct |
13 |
Correct |
12 ms |
12024 KB |
Output is correct |
14 |
Correct |
13 ms |
12056 KB |
Output is correct |
15 |
Correct |
12 ms |
12024 KB |
Output is correct |
16 |
Correct |
12 ms |
12024 KB |
Output is correct |
17 |
Correct |
17 ms |
13304 KB |
Output is correct |
18 |
Correct |
21 ms |
13304 KB |
Output is correct |
19 |
Correct |
20 ms |
13304 KB |
Output is correct |
20 |
Correct |
17 ms |
13176 KB |
Output is correct |
21 |
Correct |
18 ms |
13304 KB |
Output is correct |
22 |
Correct |
16 ms |
13304 KB |
Output is correct |
23 |
Correct |
16 ms |
13304 KB |
Output is correct |
24 |
Correct |
17 ms |
12920 KB |
Output is correct |
25 |
Correct |
71 ms |
18340 KB |
Output is correct |
26 |
Correct |
69 ms |
18296 KB |
Output is correct |
27 |
Correct |
76 ms |
18296 KB |
Output is correct |
28 |
Correct |
24 ms |
17772 KB |
Output is correct |
29 |
Correct |
31 ms |
18296 KB |
Output is correct |
30 |
Correct |
29 ms |
18424 KB |
Output is correct |
31 |
Correct |
28 ms |
18248 KB |
Output is correct |
32 |
Correct |
28 ms |
18212 KB |
Output is correct |
33 |
Correct |
550 ms |
57280 KB |
Output is correct |
34 |
Correct |
527 ms |
57308 KB |
Output is correct |
35 |
Correct |
554 ms |
34552 KB |
Output is correct |
36 |
Correct |
511 ms |
34508 KB |
Output is correct |
37 |
Correct |
2271 ms |
75896 KB |
Output is correct |
38 |
Correct |
2258 ms |
75860 KB |
Output is correct |
39 |
Correct |
2238 ms |
76168 KB |
Output is correct |
40 |
Correct |
2221 ms |
72288 KB |
Output is correct |
41 |
Correct |
106 ms |
67312 KB |
Output is correct |
42 |
Correct |
123 ms |
69112 KB |
Output is correct |
43 |
Correct |
270 ms |
74744 KB |
Output is correct |
44 |
Correct |
290 ms |
76664 KB |
Output is correct |
45 |
Correct |
138 ms |
47896 KB |
Output is correct |
46 |
Correct |
133 ms |
44536 KB |
Output is correct |
47 |
Correct |
236 ms |
74144 KB |
Output is correct |
48 |
Correct |
236 ms |
75168 KB |
Output is correct |
49 |
Correct |
13 ms |
12024 KB |
Output is correct |
50 |
Correct |
12 ms |
12024 KB |
Output is correct |
51 |
Correct |
16 ms |
12280 KB |
Output is correct |
52 |
Correct |
15 ms |
12152 KB |
Output is correct |
53 |
Correct |
14 ms |
12024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
33 ms |
24568 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
12024 KB |
Output is correct |
2 |
Runtime error |
117 ms |
76940 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
12024 KB |
Output is correct |
2 |
Correct |
15 ms |
12280 KB |
Output is correct |
3 |
Correct |
13 ms |
12280 KB |
Output is correct |
4 |
Correct |
16 ms |
12280 KB |
Output is correct |
5 |
Correct |
16 ms |
12152 KB |
Output is correct |
6 |
Correct |
15 ms |
12280 KB |
Output is correct |
7 |
Correct |
15 ms |
12280 KB |
Output is correct |
8 |
Correct |
13 ms |
12152 KB |
Output is correct |
9 |
Correct |
15 ms |
12280 KB |
Output is correct |
10 |
Correct |
13 ms |
12280 KB |
Output is correct |
11 |
Correct |
13 ms |
12280 KB |
Output is correct |
12 |
Correct |
13 ms |
12280 KB |
Output is correct |
13 |
Correct |
12 ms |
12024 KB |
Output is correct |
14 |
Correct |
13 ms |
12056 KB |
Output is correct |
15 |
Correct |
12 ms |
12024 KB |
Output is correct |
16 |
Correct |
12 ms |
12024 KB |
Output is correct |
17 |
Correct |
17 ms |
13304 KB |
Output is correct |
18 |
Correct |
21 ms |
13304 KB |
Output is correct |
19 |
Correct |
20 ms |
13304 KB |
Output is correct |
20 |
Correct |
17 ms |
13176 KB |
Output is correct |
21 |
Correct |
18 ms |
13304 KB |
Output is correct |
22 |
Correct |
16 ms |
13304 KB |
Output is correct |
23 |
Correct |
16 ms |
13304 KB |
Output is correct |
24 |
Correct |
17 ms |
12920 KB |
Output is correct |
25 |
Correct |
71 ms |
18340 KB |
Output is correct |
26 |
Correct |
69 ms |
18296 KB |
Output is correct |
27 |
Correct |
76 ms |
18296 KB |
Output is correct |
28 |
Correct |
24 ms |
17772 KB |
Output is correct |
29 |
Correct |
31 ms |
18296 KB |
Output is correct |
30 |
Correct |
29 ms |
18424 KB |
Output is correct |
31 |
Correct |
28 ms |
18248 KB |
Output is correct |
32 |
Correct |
28 ms |
18212 KB |
Output is correct |
33 |
Correct |
550 ms |
57280 KB |
Output is correct |
34 |
Correct |
527 ms |
57308 KB |
Output is correct |
35 |
Correct |
554 ms |
34552 KB |
Output is correct |
36 |
Correct |
511 ms |
34508 KB |
Output is correct |
37 |
Correct |
2271 ms |
75896 KB |
Output is correct |
38 |
Correct |
2258 ms |
75860 KB |
Output is correct |
39 |
Correct |
2238 ms |
76168 KB |
Output is correct |
40 |
Correct |
2221 ms |
72288 KB |
Output is correct |
41 |
Correct |
106 ms |
67312 KB |
Output is correct |
42 |
Correct |
123 ms |
69112 KB |
Output is correct |
43 |
Correct |
270 ms |
74744 KB |
Output is correct |
44 |
Correct |
290 ms |
76664 KB |
Output is correct |
45 |
Correct |
138 ms |
47896 KB |
Output is correct |
46 |
Correct |
133 ms |
44536 KB |
Output is correct |
47 |
Correct |
236 ms |
74144 KB |
Output is correct |
48 |
Correct |
236 ms |
75168 KB |
Output is correct |
49 |
Runtime error |
33 ms |
24568 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
50 |
Halted |
0 ms |
0 KB |
- |