Submission #721119

# Submission time Handle Problem Language Result Execution time Memory
721119 2023-04-10T10:25:22 Z saayan007 Jail (JOI22_jail) C++17
Compilation error
0 ms 0 KB
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define fr first
#define sc second
#define eb emplace_back
#define nl "\n"

const int N = 120001;
int n, m;
vector<int> adj[N];
int s[N], t[N];
int from[N];
int use[N];

void dfs(int cur, int par) {
    from[cur] = par;
    for(auto u : adj[cur]) {
        if(u != par)
            dfs(u, cur);
    }
}

void mod(int a, int b, int v = 1) {
    dfs(a, 0);
    while(b != 0) {
        use[b] += v;
        b = from[b];
    }
}

void solve() {
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        use[i] = 0;
        adj[i].clear();
    }
    for(int i = 1; i < n; ++i) {
        int a, b; cin >> a >> b;
        adj[a].eb(b); adj[b].eb(a);
    }

    cin >> m;
    for(int i = 1; i <= m; ++i) {
        cin >> s[i] >> t[i];
    }

    int o[m + 1];
    for(int i = 1; i <= m; ++i) o[i] = i;
    sort(o + 1, o + m + 1, [&](int l, int r){return {s[l], t[l]} < s[r], t[r]});

    for(int i = 1; i < m; ++i) {
        int j = order[i], k = order[i + 1];
        if(s[k] <= t[j]) {
            cout << "No" << nl;
            return;
        }
    }
    cout << "Yes" << nl;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    cin >> t;
    for(int i = 1; i <= t; ++i) {
        /* cout << "Case #" << i << nl; */
        solve();
        /* cout << nl; */
    }
}

Compilation message

jail.cpp: In lambda function:
jail.cpp:51:64: error: returning initializer list
   51 |     sort(o + 1, o + m + 1, [&](int l, int r){return {s[l], t[l]} < s[r], t[r]});
      |                                                                ^
jail.cpp:51:65: error: expected ';' before '<' token
   51 |     sort(o + 1, o + m + 1, [&](int l, int r){return {s[l], t[l]} < s[r], t[r]});
      |                                                                 ^~
      |                                                                 ;
jail.cpp:51:66: error: expected primary-expression before '<' token
   51 |     sort(o + 1, o + m + 1, [&](int l, int r){return {s[l], t[l]} < s[r], t[r]});
      |                                                                  ^
jail.cpp: In function 'void solve()':
jail.cpp:54:17: error: 'order' was not declared in this scope
   54 |         int j = order[i], k = order[i + 1];
      |                 ^~~~~
jail.cpp:55:14: error: 'k' was not declared in this scope
   55 |         if(s[k] <= t[j]) {
      |              ^