Submission #793612

# Submission time Handle Problem Language Result Execution time Memory
793612 2023-07-26T04:40:23 Z vjudge1 Tourism (JOI23_tourism) C++17
0 / 100
1 ms 596 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 3e3 + 10;

int n, m, q;

vector<int> g[N];

int sm[N];

void calc(int s, int p) {
    for(int to : g[s]) {
        if(to == p) continue;
        calc(to, s);
        sm[s] += sm[to];
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin >> n >> m >> q;
    for(int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> ver(m + 1);
    for(int i = 1; i <= m; i++) 
        cin >> ver[i];
    while(q --> 0) {
        int l, r;
        cin >> l >> r;
        for(int i = l; i <= r; i++) 
            sm[ver[i]] = 1;
        calc(1, 1);
        int res = 1;
        for(int i = 1; i <= n; i++) {
            res += (sm[i] && sm[i] < r - l + 1);
            sm[i] = 0;
        }
        cout << res << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 288 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 288 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Runtime error 1 ms 596 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 288 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -