提出 #12791770


ソースコード 拡げる

//g++  5.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> adj[200005];
ll arr[200005];
ll LIS[200005];

void DFS(ll s,ll p,vector<ll> L)
{
    ll index = lower_bound(L.begin(),L.end(),arr[s]) - L.begin();
    
    if(index == (ll)L.size())
        L.push_back(arr[s]);
    else
        L[index] = arr[s];
    
    LIS[s] = L.size();
    
    for(ll i=0;i<adj[s].size();++i)
    {
        ll c = adj[s][i];
        if(c != p)
            DFS(c,s,L);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N; cin>>N;
    
    for(ll i=1;i<=N;++i)
        cin>>arr[i];
    
    vector<ll> L;
    L.push_back(LLONG_MAX);
    
    for(ll i=0;i<(N - 1);++i)
    {
        ll u,v; cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    
    DFS(1,-1,L);
    
    for(ll i=1;i<=N;++i)
        cout<<LIS[i]<<endl;
    
}

提出情報

提出日時
問題 F - LIS on Tree
ユーザ f20160363
言語 C++ (GCC 9.2.1)
得点 0
コード長 980 Byte
結果 TLE
実行時間 2324 ms
メモリ 3497540 KiB

コンパイルエラー

./Main.cpp: In function ‘void DFS(ll, ll, std::vector<long long int>)’:
./Main.cpp:22:17: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   22 |     for(ll i=0;i<adj[s].size();++i)
      |                ~^~~~~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 600
結果
AC × 1
AC × 13
TLE × 4
セット名 テストケース
Sample Sample_01.txt
All Sample_01.txt, caterpillar_01.txt, ni_01.txt, ni_02.txt, ni_03.txt, path_02.txt, path_04.txt, path_07.txt, path_08.txt, rand_01.txt, rand_02.txt, rand_03.txt, rand_04.txt, rand_05.txt, rand_large_01.txt, same_01.txt, star_01.txt
ケース名 結果 実行時間 メモリ
Sample_01.txt AC 7 ms 8180 KiB
caterpillar_01.txt TLE 2322 ms 3483812 KiB
ni_01.txt AC 32 ms 9640 KiB
ni_02.txt AC 8 ms 8184 KiB
ni_03.txt AC 6 ms 8216 KiB
path_02.txt TLE 2324 ms 3497540 KiB
path_04.txt AC 1907 ms 512476 KiB
path_07.txt TLE 2206 ms 1036868 KiB
path_08.txt TLE 2323 ms 3496688 KiB
rand_01.txt AC 81 ms 10104 KiB
rand_02.txt AC 8 ms 8152 KiB
rand_03.txt AC 11 ms 8260 KiB
rand_04.txt AC 7 ms 8104 KiB
rand_05.txt AC 6 ms 8256 KiB
rand_large_01.txt AC 379 ms 18584 KiB
same_01.txt AC 975 ms 717552 KiB
star_01.txt AC 351 ms 18392 KiB