답안 #842150

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
842150 2023-09-02T12:50:11 Z SUNWOOOOOOOO Jail (JOI22_jail) C++17
0 / 100
1 ms 3932 KB
#include <bits/stdc++.h>
using namespace std;
using pint = array <int, 2>;
const int mxN = 120005;
vector <int> adj[mxN];
pint st[mxN];
int n, m;

void solve()
{
    for (int i = 1; i <= m; i++) {
        if (st[i][0] > st[i][1]) swap(st[i][0], st[i][1]);
    }
    sort(st + 1, st + m + 1);
    int ans = 1;
    for (int i = 1; i < m; i++){
        if (st[i][1] > st[i + 1][1]) ans = 0;
    }
    if (ans) printf("YES\n");
    else printf("NO\n");
}

int main()
{
    int q;
    scanf("%d", &q);
    while (q--) {
        scanf("%d", &n);
        for (int i = 1; i <= n; i++) adj[i].clear();
        for (int i = 0, a, b; i < n - 1; i++){
            scanf("%d %d", &a, &b);
            adj[a].push_back(b);
            adj[b].push_back(a);
        }
        scanf("%d", &m);
        for (int i = 1; i <= m; i++) {
            scanf("%d %d", &st[i][0], &st[i][1]);
        }
        solve();
    }

    return 0;
}

Compilation message

jail.cpp: In function 'int main()':
jail.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
jail.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
jail.cpp:31:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |             scanf("%d %d", &a, &b);
      |             ~~~~~^~~~~~~~~~~~~~~~~
jail.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         scanf("%d", &m);
      |         ~~~~~^~~~~~~~~~
jail.cpp:37:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |             scanf("%d %d", &st[i][0], &st[i][1]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 3932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 3932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 3932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 3932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 3932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 3932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 3932 KB Output isn't correct
2 Halted 0 ms 0 KB -