# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
64867 |
2018-08-06T00:25:38 Z |
gs18115 |
None (KOI18_matrix) |
C++14 |
|
4000 ms |
76920 KB |
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
const int INF=1e9;
const int MAXN=2e5;
struct matrix
{
int x,y,z;
matrix()
{
x=y=z=0;
}
}mat[MAXN];
bool cmp1(matrix a,matrix b)
{
return a.x<b.x;
}
bool cmp2(matrix a,matrix b)
{
return a.y<b.y;
}
bool cmp3(matrix a,matrix b)
{
return a.z<b.z;
}
set<pair<int,int> >S[MAXN];
bool fp(int x,int y,int k)
{
set<pair<int,int> >::iterator it=lower_bound(S[k].begin(),S[k].end(),make_pair(x,0));
if(it==S[k].begin())
return false;
it--;
if(it->second>y)
return false;
return true;
}
void ap(int x,int y,int k)
{
if(fp(x,y,k))
return;
while(true)
{
set<pair<int,int> >::iterator it=lower_bound(S[k].begin(),S[k].end(),make_pair(x,0));
if(it==S[k].end())
break;
else if(it->second>y)
S[k].erase(it);
else
break;
}
S[k].insert(make_pair(x,y));
return;
}
int M,N,i;
int maxi,s,e,mid;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>M>>N;
for(i=0;i<N;i++)
cin>>mat[i].x;
for(i=0;i<N;i++)
cin>>mat[i].y;
if(M==2)
for(i=0;i<N;i++)
mat[i].z=mat[i].y;
else
for(i=0;i<N;i++)
cin>>mat[i].z;
sort(mat,mat+N,cmp2);
for(i=0;i<N;i++)
mat[i].y=i+1;
sort(mat,mat+N,cmp3);
for(i=0;i<N;i++)
mat[i].z=i+1;
sort(mat,mat+N,cmp1);
ap(0,0,0);
maxi=1;
for(i=0;i<N;i++)
{
s=0;e=maxi;
while(s<e)
{
mid=s+e+1>>1;
if(fp(mat[i].y,mat[i].z,mid))
s=mid;
else
e=mid-1;
}
if(s+2>maxi)
maxi=s+2;
ap(mat[i].y,mat[i].z,s+1);
}
cout<<maxi-1;
return 0;
}
Compilation message
matrix.cpp: In function 'int main()':
matrix.cpp:88:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
mid=s+e+1>>1;
~~~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
12024 KB |
Output is correct |
2 |
Correct |
20 ms |
12296 KB |
Output is correct |
3 |
Correct |
19 ms |
12296 KB |
Output is correct |
4 |
Correct |
19 ms |
12400 KB |
Output is correct |
5 |
Correct |
22 ms |
12400 KB |
Output is correct |
6 |
Correct |
23 ms |
12732 KB |
Output is correct |
7 |
Correct |
22 ms |
12732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
12732 KB |
Output is correct |
2 |
Correct |
24 ms |
12732 KB |
Output is correct |
3 |
Correct |
35 ms |
12732 KB |
Output is correct |
4 |
Correct |
47 ms |
12732 KB |
Output is correct |
5 |
Correct |
32 ms |
12732 KB |
Output is correct |
6 |
Correct |
25 ms |
12796 KB |
Output is correct |
7 |
Correct |
46 ms |
12796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
12024 KB |
Output is correct |
2 |
Correct |
20 ms |
12296 KB |
Output is correct |
3 |
Correct |
19 ms |
12296 KB |
Output is correct |
4 |
Correct |
19 ms |
12400 KB |
Output is correct |
5 |
Correct |
22 ms |
12400 KB |
Output is correct |
6 |
Correct |
23 ms |
12732 KB |
Output is correct |
7 |
Correct |
22 ms |
12732 KB |
Output is correct |
8 |
Correct |
201 ms |
14844 KB |
Output is correct |
9 |
Correct |
225 ms |
18808 KB |
Output is correct |
10 |
Correct |
263 ms |
24720 KB |
Output is correct |
11 |
Correct |
168 ms |
26344 KB |
Output is correct |
12 |
Correct |
269 ms |
30564 KB |
Output is correct |
13 |
Correct |
269 ms |
38864 KB |
Output is correct |
14 |
Correct |
247 ms |
38864 KB |
Output is correct |
15 |
Correct |
143 ms |
41896 KB |
Output is correct |
16 |
Runtime error |
236 ms |
75588 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
12732 KB |
Output is correct |
2 |
Correct |
24 ms |
12732 KB |
Output is correct |
3 |
Correct |
35 ms |
12732 KB |
Output is correct |
4 |
Correct |
47 ms |
12732 KB |
Output is correct |
5 |
Correct |
32 ms |
12732 KB |
Output is correct |
6 |
Correct |
25 ms |
12796 KB |
Output is correct |
7 |
Correct |
46 ms |
12796 KB |
Output is correct |
8 |
Correct |
504 ms |
75588 KB |
Output is correct |
9 |
Execution timed out |
4009 ms |
76920 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |