This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*x)
#define rc (2*x+1)
using namespace std;
ll n;
ll X[150009];
ll Y[150009];
ll Z[150009];
ll mx[309][309][309][3];
int main()
{
d3
cin >> n;
for(int i = 0 ; n>i ; i++)
{
cin >> X[i] >> Y[i] >> Z[i];
mx[X[i]][Y[i]][Z[i]][0]=1;
mx[X[i]][Y[i]][Z[i]][1]=1;
mx[X[i]][Y[i]][Z[i]][2]=1;
}
for(int i = 1 ; 309>i ; i++)
{
for(int j = 1 ; 309>j ; j++)
{
for(int h = 1 ; 309>h ; h++)
{
mx[i][j][h][0]|=mx[i][j-1][h][0];
mx[i][j][h][0]|=mx[i][j][h-1][0];
mx[i][j][h][1]|=mx[i-1][j][h][1];
mx[i][j][h][1]|=mx[i][j][h-1][1];
mx[i][j][h][2]|=mx[i][j-1][h][2];
mx[i][j][h][2]|=mx[i-1][j][h][2];
}
}
}
int ans = -1;
for(int i = 1 ; 309>i ; i++)
{
for(int j = 1 ; 309>j ; j++)
{
for(int h = 1 ; 309>h ; h++)
{
if(mx[i][j-1][h-1][0]&&mx[i-1][j][h-1][1]&&mx[i-1][j-1][h][2])
ans=max(ans,i+j+h);
}
}
}
cans
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |