Submission #586138

# Submission time Handle Problem Language Result Execution time Memory
586138 2022-06-30T02:14:19 Z nota Team Contest (JOI22_team) C++14
0 / 100
1 ms 212 KB
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<int, int>
using namespace std;
const int maxN = 501;
int n;
pii x[maxN], y[maxN], z[maxN];

void Input()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> x[i].fi >> y[i].fi >> z[i].fi;
        x[i].se = y[i].se = z[i].se = i;
    }
}

bool flag[maxN];

void Solve()
{
    fill(flag + 1, flag + 1 + n, false);
    sort(x+1, x+1+n);
    sort(y+1, y+1+n);
    sort(z+1, z+1+n);
    int resx = n, resy = n, resz = n;
    while(resx != 0 && resy != 0 && resz != 0)
    {
        int tmpx = x[resx].fi, tmpy = y[resy].fi, tmpz = z[resz].fi;
        int xx = (y[x[resx].se].fi == tmpy) + (z[x[resx].se].fi == tmpz);
        int yy = (x[y[resy].se].fi == tmpx) + (z[y[resy].se].fi == tmpz);
        int zz = (x[z[resz].se].fi == tmpx) + (y[z[resz].se].fi == tmpy);
        if(xx == 0 && yy == 0 && zz == 0)
        {
            cout << tmpx + tmpy + tmpz;
            return;
        }
        if(xx > 0)
        {
            flag[x[resx].se] = true;
            goto hi;
        }
        if(yy > 0)
        {
            flag[y[resy].se] = true;
            goto hi;
        }
        if(zz > 0)
        {
            flag[z[resz].se] = true;
            goto hi;
        }
        hi:
        if(flag[x[resx].se])
            resx--;
        if(flag[y[resy].se])
            resy--;
        if(flag[z[resz].se])
            resz--;
    }
    cout << -1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    Input();
    Solve();
}


# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -