답안 #878023

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
878023 2023-11-24T02:44:43 Z Regulus Jail (JOI22_jail) C++17
21 / 100
5000 ms 6848 KB
#include <bits/stdc++.h>            // pA
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define debug(x) cerr << #x << " = " << (x) << ' '
#define endl cerr << '\n'
#define all(v) (v).begin(), (v).end()
#define SZ(v) (ll)(v).size()
#define lowbit(x) (x)&-(x)
#define pb emplace_back
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

const int N = 2e5+5;
//const int INF = 2e9;
int s[N], t[N], idx[N], a[N];
vector<int> g[N];

inline bool run(int x, int pre, int ed)
{
    if (a[x]) return 0;
    if (x == ed) return 1;
    bool ret = 0;
    for (int v : g[x]) if (v != pre) ret |= run(v, x, ed);
    return ret;
}

int main(void)
{ IO
    ll T, n, i, m, x, y;
    bool ff;

    cin >> T;
    do {
        cin >> n;
        for (i=1; i <= n; ++i) g[i].clear();
        for (i=0; i < n-1; ++i) cin >> x >> y, g[x].pb(y), g[y].pb(x);

        cin >> m;
        for (i=1; i <= m; ++i) cin >> s[i] >> t[i], idx[i] = i;
        ff = 0;
        do {
            for (i=1; i <= n; ++i) a[i] = 0;
            for (i=1; i <= m; ++i) a[s[i]] = 1;

            for (i=1; i <= m; ++i)
            {
                x = idx[i], a[s[x]] = 0;
                if (!run(s[x], 0, t[x])) break;
                a[t[x]] = 1;
            }
            if (i > m) ff = 1;
        } while (next_permutation(idx+1, idx+m+1));

        if (ff) cout << "Yes\n";
        else cout << "No\n";
    } while (--T);

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 8 ms 6748 KB Output is correct
5 Correct 15 ms 6812 KB Output is correct
6 Correct 2 ms 6748 KB Output is correct
7 Correct 11 ms 6808 KB Output is correct
8 Execution timed out 5029 ms 6744 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 2 ms 6748 KB Output is correct
4 Correct 2 ms 6748 KB Output is correct
5 Correct 2 ms 6748 KB Output is correct
6 Correct 2 ms 6748 KB Output is correct
7 Correct 2 ms 6748 KB Output is correct
8 Correct 2 ms 6744 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 2 ms 6748 KB Output is correct
11 Correct 2 ms 6748 KB Output is correct
12 Correct 2 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 2 ms 6748 KB Output is correct
4 Correct 2 ms 6748 KB Output is correct
5 Correct 2 ms 6748 KB Output is correct
6 Correct 2 ms 6748 KB Output is correct
7 Correct 2 ms 6748 KB Output is correct
8 Correct 2 ms 6744 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 2 ms 6748 KB Output is correct
11 Correct 2 ms 6748 KB Output is correct
12 Correct 2 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 2 ms 6748 KB Output is correct
15 Correct 2 ms 6748 KB Output is correct
16 Correct 11 ms 6744 KB Output is correct
17 Correct 17 ms 6748 KB Output is correct
18 Correct 19 ms 6748 KB Output is correct
19 Correct 1 ms 6748 KB Output is correct
20 Correct 56 ms 6748 KB Output is correct
21 Correct 22 ms 6744 KB Output is correct
22 Correct 37 ms 6848 KB Output is correct
23 Correct 2 ms 6748 KB Output is correct
24 Correct 3 ms 6748 KB Output is correct
25 Correct 52 ms 6828 KB Output is correct
26 Correct 13 ms 6748 KB Output is correct
27 Correct 30 ms 6744 KB Output is correct
28 Correct 6 ms 6748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 2 ms 6748 KB Output is correct
4 Correct 2 ms 6748 KB Output is correct
5 Correct 2 ms 6748 KB Output is correct
6 Correct 2 ms 6748 KB Output is correct
7 Correct 2 ms 6748 KB Output is correct
8 Correct 2 ms 6744 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 2 ms 6748 KB Output is correct
11 Correct 2 ms 6748 KB Output is correct
12 Correct 2 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 2 ms 6748 KB Output is correct
15 Correct 2 ms 6748 KB Output is correct
16 Correct 11 ms 6744 KB Output is correct
17 Correct 17 ms 6748 KB Output is correct
18 Correct 19 ms 6748 KB Output is correct
19 Correct 1 ms 6748 KB Output is correct
20 Correct 56 ms 6748 KB Output is correct
21 Correct 22 ms 6744 KB Output is correct
22 Correct 37 ms 6848 KB Output is correct
23 Correct 2 ms 6748 KB Output is correct
24 Correct 3 ms 6748 KB Output is correct
25 Correct 52 ms 6828 KB Output is correct
26 Correct 13 ms 6748 KB Output is correct
27 Correct 30 ms 6744 KB Output is correct
28 Correct 6 ms 6748 KB Output is correct
29 Execution timed out 5064 ms 6748 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 2 ms 6748 KB Output is correct
4 Correct 2 ms 6748 KB Output is correct
5 Correct 2 ms 6748 KB Output is correct
6 Correct 2 ms 6748 KB Output is correct
7 Correct 2 ms 6748 KB Output is correct
8 Correct 2 ms 6744 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 2 ms 6748 KB Output is correct
11 Correct 2 ms 6748 KB Output is correct
12 Correct 2 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 2 ms 6748 KB Output is correct
15 Correct 2 ms 6748 KB Output is correct
16 Correct 11 ms 6744 KB Output is correct
17 Correct 17 ms 6748 KB Output is correct
18 Correct 19 ms 6748 KB Output is correct
19 Correct 1 ms 6748 KB Output is correct
20 Correct 56 ms 6748 KB Output is correct
21 Correct 22 ms 6744 KB Output is correct
22 Correct 37 ms 6848 KB Output is correct
23 Correct 2 ms 6748 KB Output is correct
24 Correct 3 ms 6748 KB Output is correct
25 Correct 52 ms 6828 KB Output is correct
26 Correct 13 ms 6748 KB Output is correct
27 Correct 30 ms 6744 KB Output is correct
28 Correct 6 ms 6748 KB Output is correct
29 Execution timed out 5064 ms 6748 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Execution timed out 5084 ms 6776 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 8 ms 6748 KB Output is correct
5 Correct 15 ms 6812 KB Output is correct
6 Correct 2 ms 6748 KB Output is correct
7 Correct 11 ms 6808 KB Output is correct
8 Execution timed out 5029 ms 6744 KB Time limit exceeded
9 Halted 0 ms 0 KB -