이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std ;
const int N = 15e4 ;
bool flag1, flag2 = 0 ;
int n, ans = -1, x[N + 1], y[N + 1], z[N + 1] ;
set<pair<int, pair<int, int>>> s ;
vector<pair<int, pair<int, int>>> v ;
int func(int i, int j, int q)
{
if(x[i] > x[j] && x[i] > x[q] && y[j] > y[i] && y[j] > y[q] && z[i] < z[q] && z[j] < z[q])
return x[i] + y[j] + z[q] ;
else
return -1 ;
}
int func1(int i, int j, int q)
{
if(v[i].fi > v[j].fi && v[i].fi > v[q].fi && v[j].se.fi > v[i].se.fi && v[j].se.fi > v[q].se.fi && v[i].se.se < v[q].se.se && v[j].se.se < v[q].se.se)
return v[i].fi + v[j].se.fi + v[q].se.se ;
else
return -1 ;
}
signed main()
{
ios_base::sync_with_stdio( 0 ) ;
cin.tie( 0 ) ;
cout.tie( 0 ) ;
cin >> n ;
for(int i = 1 ; i <= n ; i++)
{
cin >> x[i] >> y[i] >> z[i] ;
if(x[i] > 5 || y[i] > 5 || z[i] > 5)flag1 = 1 ;
if(x[i] > 20 || y[i] > 20 || z[i] > 20)flag2 = 1 ;
s.insert({x[i], {y[i], z[i]}}) ;
}
if(!flag2)
{
for(auto i : s)
v.push_back(i) ;
for(int i = 1 ; i <= 20 ; i++)
for(int j = 1 ; j <= 20 ; j++)
for(int q = 1 ; q <= 20 ; q++)
{
bool fl1 = 0, fl2 = 0, fl3 = 0 ;
for(auto now : v)
{
if(now.fi == i && now.se.fi < j && now.se.se < q)fl1 = 1 ;
if(now.fi < i && now.se.fi == j && now.se.se < q)fl2 = 1 ;
if(now.fi < i && now.se.fi < j && now.se.se == q)fl3 = 1 ;
}
// if(i == 5 && j == 4 && q == 4)
// cout << fl1 << ' ' << fl2 << ' ' << fl3 << '\n' ;
if(fl1 && fl2 && fl3)
ans = max(ans, i + j + q) ;
}
cout << ans ;
return 0 ;
}
if(!flag1)
{
for(auto i : s)
v.push_back(i) ;
for(int i = 0 ; i < v.size() ; i++)
for(int j = 0 ; j < v.size() ; j++)
{
if(i == j)
continue ;
for(int q = 0 ; q < v.size() ; q++)
{
if(i == q || q == j)
continue ;
ans = max(ans, func1(i, j, q)) ;
}
}
cout << ans ;
return 0 ;
}
if(n <= 300)
{
for(int i = 1 ; i <= n ; i++)
for(int j = 1 ; j <= n ; j++)
{
if(i == j)
continue ;
for(int q = 1 ; q <= n ; q++)
{
if(j == q || i == q)
continue ;
ans = max(ans, func(i, j, q)) ;
}
}
cout << ans << '\n' ;
return 0 ;
}
if(n <= 4000)
{
cout << ans << '\n' ;
return 0 ;
}
return 0 ;
}
컴파일 시 표준 에러 (stderr) 메시지
team.cpp: In function 'int main()':
team.cpp:64:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | for(int i = 0 ; i < v.size() ; i++)
| ~~^~~~~~~~~~
team.cpp:65:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for(int j = 0 ; j < v.size() ; j++)
| ~~^~~~~~~~~~
team.cpp:69:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for(int q = 0 ; q < v.size() ; q++)
| ~~^~~~~~~~~~
# | 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... |