답안 #367505

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
367505 2021-02-17T14:25:30 Z cpp219 Uzastopni (COCI15_uzastopni) C++14
56 / 160
500 ms 65540 KB
#include <bits/stdc++.h>
#define ll int
#define ld long double
#define fs first
#define sc second
using namespace std;
const ll N = 2e4 + 9;
const ll inf = 1e9 + 7;
typedef pair<int,int> LL;
vector<ll> g[N];
ll n,v[N],x,y;
bitset<210> flag[N][210];
vector<LL> s[N];
void DFS(ll u){
    for (auto i : g[u]) DFS(i); vector<ll> q[N];
    for (auto i : g[u]){
        for (auto j : s[i]) q[j.fs].push_back(j.sc);
    }
    for (ll l = 109;l > 0;l--){
        if (l == v[u]){
            flag[u][l] |= flag[u][l + 1]; flag[u][l].set(l);
        }
        else{
            for (auto i : q[l]){
                if (l > v[u] || i < v[u]){
                    flag[u][l] |= flag[u][i + 1]; flag[u][l].set(i);
                }
            }
        }
        for (ll i = 100;i >= l;i--) if (flag[u][l][i] == 1 && l <= v[u] && i >= v[u]) s[u].push_back({l,i});
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #define task "tst"
    if (fopen(task".INP","r")){
        freopen(task".INP","r",stdin);
        //freopen(task".OUT","w",stdout);
    }
    cin>>n;
    for (ll i = 1;i <= n;i++) cin>>v[i];
    for (ll i = 1;i < n;i++) cin>>x>>y,g[x].push_back(y);
    DFS(1); cout<<s[1].size();
}

Compilation message

uzastopni.cpp: In function 'void DFS(int)':
uzastopni.cpp:15:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   15 |     for (auto i : g[u]) DFS(i); vector<ll> q[N];
      |     ^~~
uzastopni.cpp:15:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   15 |     for (auto i : g[u]) DFS(i); vector<ll> q[N];
      |                                 ^~~~~~
uzastopni.cpp: In function 'int main()':
uzastopni.cpp:39:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   39 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5228 KB Output is correct
2 Correct 7 ms 5740 KB Output is correct
3 Correct 13 ms 6252 KB Output is correct
4 Correct 9 ms 5868 KB Output is correct
5 Correct 13 ms 6380 KB Output is correct
6 Runtime error 24 ms 34668 KB Memory limit exceeded
7 Runtime error 26 ms 35180 KB Memory limit exceeded
8 Runtime error 24 ms 35180 KB Memory limit exceeded
9 Correct 9 ms 4972 KB Output is correct
10 Correct 9 ms 4972 KB Output is correct
11 Execution timed out 626 ms 52460 KB Time limit exceeded
12 Execution timed out 624 ms 52952 KB Time limit exceeded
13 Execution timed out 623 ms 53228 KB Time limit exceeded
14 Runtime error 53 ms 65540 KB Execution killed with signal 9
15 Runtime error 51 ms 65540 KB Execution killed with signal 9
16 Runtime error 51 ms 65540 KB Execution killed with signal 9
17 Execution timed out 622 ms 52844 KB Time limit exceeded
18 Execution timed out 629 ms 53228 KB Time limit exceeded
19 Execution timed out 598 ms 49772 KB Time limit exceeded
20 Execution timed out 610 ms 49756 KB Time limit exceeded