답안 #850353

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
850353 2023-09-16T12:29:28 Z niter Team Contest (JOI22_team) C++17
17 / 100
2000 ms 2904 KB
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define pb push_back
#define ins insert
#define ff first
#define ss second
#define opa(x) cout << #x << " = " << x << ", ";
#define op(x) cout << #x << " = " << x << "\n";
#define ops(x) cout << x;
#define entr cout << '\n';
#define spac cout << ' ';
#define all(x) (x).begin(), (x).end()
#define STL(x) cout << #x << " : "; for(auto &qwe:x) cout << qwe << ' '; cout << endl;
#define deb1 cout << "deb1" << endl;
#define deb2 cout << "deb2" << endl;
#define deb3 cout << "deb3" << endl;
#define deb4 cout << "deb4" << endl;
#define deb5 cout << "deb5" << endl;
using namespace std;
typedef long long ll;

struct pp{
    int x, y, z;
    void read(){
        cin >> x >> y >> z;
    }
    string res(){
//        cout << x << y << z << "test\n";
        return ("[" + to_string(x) + ", " + to_string(y) + ", " + to_string(z) + "]");
    }
    bool operator<(pp A){
        return (x == A.x) ? ( (y == A.y) ? (z > A.z) : (y > A.y) ) : (x > A.x);
    }
};
ostream& operator<<(ostream& os, pp A){
//    cerr << "test1";
    os << A.res();
}
bool dp[21][21][21];

void solve2(vector<pp> &v){
    int n = v.size();
    loop(i,0,n){
        int tx = v[i].x, ty = v[i].y, tz = v[i].z;
        dp[tx][ty][tz] = true;
    }
    int ans = -1;
    loop(x1,1,6) loop(y1,1,6) loop(z1,1,6){
        loop(x2,1,x1) loop(y2,y1+1,6) loop(z2,1,6){
            loop(x3,1,x1) loop(y3,1,y2) loop(z3,max(z1,z2)+1,6){
                if(dp[x1][y1][z1] && dp[x2][y2][z2] && dp[x3][y3][z3]){
                    ans = max(ans, x1 + y2 + z3);
                }
            }
        }
    }
    cout << ans << '\n';
}

void solve(){
    int n; cin >> n;
    vector<pp> v(n);
    bool flag = true;
    loop(i,0,n){
        v[i].read();
        if(v[i].x > 5 || v[i].y > 5 || v[i].z > 5){
            flag = false;
        }
    }
//    loop(i,0,n){
//        op(v[i].res());
//    }
    if(flag){
        solve2(v);
        return;
    }
    sort(all(v));
    int ans = -1;
    loop(i,0,n){
        loop(j,i+1,n){
            loop(k,j+1,n){
                if(j == k) continue;
                pp tmp1 = v[j];
                pp tmp2 = v[k];
                if(tmp1.y == tmp2.y || tmp1.z == tmp2.z) continue;
                if(tmp1.y < tmp2.y) swap(tmp1, tmp2);
                if(v[i].x > v[j].x && v[i].x > v[k].x && tmp1.y > tmp2.y && tmp1.y > v[i].y
                   && tmp2.z > tmp1.z && tmp2.z > v[i].z){
                        ans = max(ans, v[i].x + tmp1.y + tmp2.z);
                }
            }
        }
    }
    cout << ans << '\n';
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
//    freopen("test_input.txt", "r", stdin);
    int t = 1;
    while(t--){
        solve();
    }
}

Compilation message

team.cpp: In function 'std::ostream& operator<<(std::ostream&, pp)':
team.cpp:39:1: warning: no return statement in function returning non-void [-Wreturn-type]
   39 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 26 ms 456 KB Output is correct
15 Correct 10 ms 344 KB Output is correct
16 Correct 16 ms 344 KB Output is correct
17 Correct 17 ms 344 KB Output is correct
18 Correct 21 ms 344 KB Output is correct
19 Correct 25 ms 344 KB Output is correct
20 Correct 15 ms 344 KB Output is correct
21 Correct 8 ms 344 KB Output is correct
22 Correct 8 ms 348 KB Output is correct
23 Correct 8 ms 344 KB Output is correct
24 Correct 12 ms 456 KB Output is correct
25 Correct 12 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 26 ms 456 KB Output is correct
15 Correct 10 ms 344 KB Output is correct
16 Correct 16 ms 344 KB Output is correct
17 Correct 17 ms 344 KB Output is correct
18 Correct 21 ms 344 KB Output is correct
19 Correct 25 ms 344 KB Output is correct
20 Correct 15 ms 344 KB Output is correct
21 Correct 8 ms 344 KB Output is correct
22 Correct 8 ms 348 KB Output is correct
23 Correct 8 ms 344 KB Output is correct
24 Correct 12 ms 456 KB Output is correct
25 Correct 12 ms 344 KB Output is correct
26 Execution timed out 2039 ms 344 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 18 ms 2140 KB Output is correct
12 Correct 13 ms 2140 KB Output is correct
13 Correct 18 ms 2904 KB Output is correct
14 Correct 18 ms 2904 KB Output is correct
15 Correct 18 ms 2904 KB Output is correct
16 Correct 18 ms 2860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 18 ms 2140 KB Output is correct
12 Correct 13 ms 2140 KB Output is correct
13 Correct 18 ms 2904 KB Output is correct
14 Correct 18 ms 2904 KB Output is correct
15 Correct 18 ms 2904 KB Output is correct
16 Correct 18 ms 2860 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 14 ms 344 KB Output is correct
21 Execution timed out 2103 ms 600 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 18 ms 2140 KB Output is correct
12 Correct 13 ms 2140 KB Output is correct
13 Correct 18 ms 2904 KB Output is correct
14 Correct 18 ms 2904 KB Output is correct
15 Correct 18 ms 2904 KB Output is correct
16 Correct 18 ms 2860 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 14 ms 344 KB Output is correct
21 Execution timed out 2103 ms 600 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 18 ms 2140 KB Output is correct
12 Correct 13 ms 2140 KB Output is correct
13 Correct 18 ms 2904 KB Output is correct
14 Correct 18 ms 2904 KB Output is correct
15 Correct 18 ms 2904 KB Output is correct
16 Correct 18 ms 2860 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 14 ms 344 KB Output is correct
21 Execution timed out 2103 ms 600 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 26 ms 456 KB Output is correct
15 Correct 10 ms 344 KB Output is correct
16 Correct 16 ms 344 KB Output is correct
17 Correct 17 ms 344 KB Output is correct
18 Correct 21 ms 344 KB Output is correct
19 Correct 25 ms 344 KB Output is correct
20 Correct 15 ms 344 KB Output is correct
21 Correct 8 ms 344 KB Output is correct
22 Correct 8 ms 348 KB Output is correct
23 Correct 8 ms 344 KB Output is correct
24 Correct 12 ms 456 KB Output is correct
25 Correct 12 ms 344 KB Output is correct
26 Execution timed out 2039 ms 344 KB Time limit exceeded
27 Halted 0 ms 0 KB -