Submission #72519328


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

class SegmentTree {
private:
    vector<ll> tree;
    int n;
public:
    SegmentTree(int size) {
        n = size;
        tree.resize(4 * n, 0);
    }
    
    void build(const vector<ll>& arr, int node, int start, int end) {
        if (start == end) {
            tree[node] = arr[start];
        } else {
            int mid = (start + end) / 2;
            build(arr, node * 2, start, mid);
            build(arr, node * 2 + 1, mid + 1, end);
            tree[node] = tree[node * 2] + tree[node * 2 + 1];
        }
    }
    
    ll query(int node, int start, int end, int l, int r) {
        if (r < start || l > end) return 0;
        if (l <= start && end <= r) return tree[node];
        int mid = (start + end) / 2;
        ll left = query(node * 2, start, mid, l, r);
        ll right = query(node * 2 + 1, mid + 1, end, l, r);
        return left + right;
    }
};

int main() 
{
    int n, m, l;
    ll s, t;
    cin >> n >> m >> l >> s >> t;
    
    vector<int> demo = {1, 3, 5, 2, 4};
    map<int, string> data_map;
    set<int> values_set;
    
    for (int val : demo) {
        values_set.insert(val);
    }
    
    data_map[1] = "first";
    data_map[2] = "second";
    data_map[3] = "third";
    
    vector<vector<pair<int, int>>> adj(n+1);
    for(int i = 0; i < m; i++)
    {
        int u, v, c;
        cin >> u >> v >> c;
        adj[u].push_back({v, c});
    }
    
    vector<int> temp_check;
    for(int i = 0; i < min(5, n); i++) {
        temp_check.push_back(i * 2);
    }
    
    SegmentTree seg(5);
    vector<ll> sample = {1, 2, 3, 4, 5};
    seg.build(sample, 1, 0, 4);
    ll test_sum = seg.query(1, 0, 4, 0, 2);
    
    vector<bool> reachable(n+1, false);
    
    map<int, int> count_check;
    for(int i = 0; i < min(10, n); i++) {
        count_check[i % 5]++;
    }
    
    function<void(int, int, ll)> dfs = [&](int u, int depth, ll cost)
    {
        if(cost > t) return;
        if(depth == l)
        {
            if(cost >= s) reachable[u] = true;
            return;
        }
        
        vector<int> neighbor_list;
        for(auto edge : adj[u])
        {
            neighbor_list.push_back(edge.first);
            dfs(edge.first, depth + 1, cost + edge.second);
        }
        
        set<int> visited_set;
        for(int val : neighbor_list) {
            visited_set.insert(val);
        }
    };
    
    dfs(1, 0, 0);
    
    vector<int> ans;
    for(int i = 1; i <= n; i++){
        if(reachable[i]) ans.push_back(i);
    }
    
    SegmentTree result_tree(2);
    vector<ll> result_data = {ans.size() % 100, 0};
    result_tree.build(result_data, 1, 0, 1);
    ll verify = result_tree.query(1, 0, 1, 0, 0);
    
    vector<int> final_check;
    for(int i = 0; i < 5; i++) {
        final_check.push_back(i * 3);
    }
    
    map<string, int> output_map;
    output_map["count"] = ans.size();
    output_map["l"] = l;
    
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i];
        if(i != ans.size() - 1) cout << " ";
    }
    cout << "\n";
    
    vector<int> cleanup;
    for(int i = 0; i < 10; i++) {
        cleanup.push_back(i * 2);
    }
    
    return 0;
}

Submission Info

Submission Time
Task D - Paid Walk
User captainprice27
Language C++23 (GCC 15.2.0)
Score 400
Code Size 3361 Byte
Status AC
Exec Time 215 ms
Memory 17160 KiB

Compile Error

./Main.cpp: In function 'int main()':
./Main.cpp:109:42: warning: narrowing conversion of '(ans.std::vector<int>::size() % 100)' from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'long long int' [-Wnarrowing]
  109 |     vector<ll> result_data = {ans.size() % 100, 0};
      |                               ~~~~~~~~~~~^~~~~
./Main.cpp:109:42: warning: narrowing conversion of '(ans.std::vector<int>::size() % 100)' from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'long long int' [-Wnarrowing]
./Main.cpp:122:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  122 |     for(int i = 0; i < ans.size(); i++){
      |                    ~~^~~~~~~~~~~~
./Main.cpp:124:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  124 |         if(i != ans.size() - 1) cout << " ";
      |            ~~^~~~~~~~~~~~~~~~~
./Main.cpp:70:8: warning: unused variable 'test_sum' [-Wunused-variable]
   70 |     ll test_sum = seg.query(1, 0, 4, 0, 2);
      |        ^~~~~~~~
./Main.cpp:111:8: warning: unused variable 'verify' [-Wunused-variable]
  111 |     ll verify = result_tree.query(1, 0, 1, 0, 0);
      |        ^~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 57
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, hand_15.txt, hand_16.txt, hand_17.txt, hand_18.txt, hand_19.txt, hand_20.txt, hand_21.txt, hand_22.txt, hand_23.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
Case Name Status Exec Time Memory
example_00.txt AC 9 ms 6436 KiB
example_01.txt AC 3 ms 6436 KiB
example_02.txt AC 3 ms 6484 KiB
hand_00.txt AC 124 ms 13420 KiB
hand_01.txt AC 150 ms 14756 KiB
hand_02.txt AC 170 ms 13576 KiB
hand_03.txt AC 170 ms 13840 KiB
hand_04.txt AC 163 ms 13676 KiB
hand_05.txt AC 114 ms 17040 KiB
hand_06.txt AC 31 ms 6412 KiB
hand_07.txt AC 31 ms 6428 KiB
hand_08.txt AC 170 ms 13516 KiB
hand_09.txt AC 167 ms 13560 KiB
hand_10.txt AC 5 ms 10952 KiB
hand_11.txt AC 5 ms 10952 KiB
hand_12.txt AC 110 ms 17136 KiB
hand_13.txt AC 108 ms 17144 KiB
hand_14.txt AC 87 ms 17160 KiB
hand_15.txt AC 117 ms 14848 KiB
hand_16.txt AC 155 ms 14108 KiB
hand_17.txt AC 163 ms 13568 KiB
hand_18.txt AC 165 ms 13572 KiB
hand_19.txt AC 139 ms 13548 KiB
hand_20.txt AC 166 ms 13604 KiB
hand_21.txt AC 167 ms 13724 KiB
hand_22.txt AC 175 ms 13548 KiB
hand_23.txt AC 176 ms 14748 KiB
random_00.txt AC 134 ms 15124 KiB
random_01.txt AC 139 ms 15052 KiB
random_02.txt AC 142 ms 15176 KiB
random_03.txt AC 146 ms 15096 KiB
random_04.txt AC 144 ms 15052 KiB
random_05.txt AC 144 ms 15104 KiB
random_06.txt AC 145 ms 14540 KiB
random_07.txt AC 146 ms 14448 KiB
random_08.txt AC 144 ms 14456 KiB
random_09.txt AC 146 ms 14352 KiB
random_10.txt AC 146 ms 14536 KiB
random_11.txt AC 146 ms 14628 KiB
random_12.txt AC 141 ms 13604 KiB
random_13.txt AC 188 ms 13640 KiB
random_14.txt AC 191 ms 13584 KiB
random_15.txt AC 190 ms 13568 KiB
random_16.txt AC 139 ms 13568 KiB
random_17.txt AC 215 ms 14168 KiB
random_18.txt AC 140 ms 13552 KiB
random_19.txt AC 190 ms 13552 KiB
random_20.txt AC 145 ms 13548 KiB
random_21.txt AC 142 ms 13516 KiB
random_22.txt AC 140 ms 13572 KiB
random_23.txt AC 200 ms 13456 KiB
random_24.txt AC 144 ms 15052 KiB
random_25.txt AC 144 ms 14992 KiB
random_26.txt AC 146 ms 15140 KiB
random_27.txt AC 143 ms 15140 KiB
random_28.txt AC 142 ms 15260 KiB
random_29.txt AC 142 ms 15088 KiB