Submission #674680

#TimeUsernameProblemLanguageResultExecution timeMemory
674680Nicolas125841Burza (COCI16_burza)Java
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define YES "DA" #define NO "NE" vector<vector<int>> layers; vector<int> ways; unordered_map<int, bitset<400>> coverage; bitset<400> dfs(vector<vector<int>> &mp, int n, int p, int d, int k){ if(layers.size() == d){ layers.push_back(vector<int>()); ways.push_back(0); } if(d == k){ coverage[n] |= 1; coverage[n] <<= layers[d].size(); } layers[d].push_back(n); for(int v : mp[n]){ if(v != p){ bitset<400> res = dfs(mp, v, n, d+1, k); if(layers.size() > k && d < k) coverage[n] |= res; } } if(coverage[n] != 0) ways[d]++; return coverage[n]; } int main(){ cin.tie(NULL)->sync_with_stdio(false); int n, k; cin >> n >> k; vector<vector<int>> mp(n, vector<int>()); for(int i = 0; i < n-1; i++){ int u, v; cin >> u >> v; mp[--u].push_back(--v); mp[v].push_back(u); } dfs(mp, 0, -1, 0, k); if(layers.size() <= k) cout << YES << "\n"; else{ unordered_set<bitset<400>> cur, prev = {bitset<400>()}; bool g = false; for(int i = 1; i <= k; i++){ for(bitset<400> bs : prev){ for(int v : layers[i]){ if(coverage[v] == 0 || (coverage[v].count() == 1 && layers[k].size()-bs.count() > (k-1)+1)) continue; if((coverage[v] & bs) == 0){ cur.insert(coverage[v] | bs); if((coverage[v] | bs).count() == layers[k].size()) g = true; } } } swap(cur, prev); cur.clear(); } cout << (g ? YES : NO) << "\n"; } }

Compilation message (stderr)

burza.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
burza.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
         ^
burza.java:5: error: illegal character: '#'
#define YES "DA"
^
burza.java:5: error: class, interface, or enum expected
#define YES "DA"
        ^
burza.java:6: error: illegal character: '#'
#define NO "NE"
^
burza.java:9: error: class, interface, or enum expected
vector<int> ways;
^
burza.java:10: error: class, interface, or enum expected
unordered_map<int, bitset<400>> coverage;
^
burza.java:12: error: class, interface, or enum expected
bitset<400> dfs(vector<vector<int>> &mp, int n, int p, int d, int k){
^
burza.java:15: error: class, interface, or enum expected
        ways.push_back(0);
        ^
burza.java:16: error: class, interface, or enum expected
    }
    ^
burza.java:20: error: class, interface, or enum expected
        coverage[n] <<= layers[d].size();
        ^
burza.java:21: error: class, interface, or enum expected
    }
    ^
burza.java:25: error: class, interface, or enum expected
    for(int v : mp[n]){        
    ^
burza.java:29: error: class, interface, or enum expected
            if(layers.size() > k && d < k)
            ^
burza.java:31: error: class, interface, or enum expected
        }
        ^
burza.java:37: error: class, interface, or enum expected
    return coverage[n];
    ^
burza.java:38: error: class, interface, or enum expected
}
^
burza.java:43: error: class, interface, or enum expected
    int n, k;
    ^
burza.java:44: error: class, interface, or enum expected
    cin >> n >> k;
    ^
burza.java:46: error: class, interface, or enum expected
    vector<vector<int>> mp(n, vector<int>());    
    ^
burza.java:48: error: class, interface, or enum expected
    for(int i = 0; i < n-1; i++){
    ^
burza.java:48: error: class, interface, or enum expected
    for(int i = 0; i < n-1; i++){
                   ^
burza.java:48: error: class, interface, or enum expected
    for(int i = 0; i < n-1; i++){
                            ^
burza.java:51: error: class, interface, or enum expected
        cin >> u >> v;
        ^
burza.java:53: error: class, interface, or enum expected
        mp[--u].push_back(--v);
        ^
burza.java:54: error: class, interface, or enum expected
        mp[v].push_back(u);
        ^
burza.java:56: error: class, interface, or enum expected
    }
    ^
burza.java:60: error: class, interface, or enum expected
    if(layers.size() <= k)
    ^
burza.java:62: error: class, interface, or enum expected
    else{
    ^
burza.java:64: error: class, interface, or enum expected
        bool g = false;
        ^
burza.java:66: error: class, interface, or enum expected
        for(int i = 1; i <= k; i++){
        ^
burza.java:66: error: class, interface, or enum expected
        for(int i = 1; i <= k; i++){
                       ^
burza.java:66: error: class, interface, or enum expected
        for(int i = 1; i <= k; i++){
                               ^
burza.java:72: error: class, interface, or enum expected
                    if((coverage[v] & bs) == 0){
                    ^
burza.java:75: error: class, interface, or enum expected
                        if((coverage[v] | bs).count() == layers[k].size())
                        ^
burza.java:77: error: class, interface, or enum expected
                    }                
                    ^
burza.java:82: error: class, interface, or enum expected
            cur.clear();
            ^
burza.java:83: error: class, interface, or enum expected
        }
        ^
burza.java:86: error: class, interface, or enum expected
    }
    ^
39 errors