답안 #1092465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1092465 2024-09-24T07:17:34 Z modwwe Construction Project 2 (JOI24_ho_t2) C++17
100 / 100
181 ms 29428 KB
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define int long long
//#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
#define getchar_unlocked getchar

inline int scan()
{
    char c = getchar_unlocked();
    int x = 0;
    while (c < '0' || c > '9')
    {
        c = getchar_unlocked();
    }
    while (c >= '0' && c <= '9')
    {
        x = (x << 1) + (x << 3) + c - '0';
        c = getchar_unlocked();
    }
    return x;
}

void phongbeo();
const int inf = 1e17;
const int mod2 = 1e9 + 9;
const int  mod1 = 998244353;
struct icd
{
    long double a;
    int b;
};
struct ib
{
    int a;
    int b;
};
struct ic
{
    int a, b, c;
};
struct id
{
    int a, b, c, d;
};
struct ie
{
    int a, b, c, d, e;

};

int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, l, r, mid, l2, r2, center;
int  i, s10, s12,k1,k2,s11;
int kk;
int el = 19;
main()
{
    //fin(task);
   // fou(task);
    NHP
    /// cin>>s1;
///modwwe
    phongbeo();
    // checktime
}
int s,t;
int a[200001];
int b[200001];
vector<ib> v[200001];
struct cmp
{
    bool operator()(ib a,ib b)
    {
        return a.b>b.b;
    }
};
void dist(int x,int c[])
{
    priority_queue<ib,vector<ib>,cmp>p;
    p.push({x,0});
    while(!p.empty())
    {
        ib x=p.top();
        p.pop();
        if(c[x.a]!=-1) continue;
        c[x.a]=x.b;
        for(auto f:v[x.a])
            if(c[f.a]==-1)
                p.push({f.a,f.b+x.b});
    }
}
void phongbeo()
{
    cin>>n>>m;
    cin>>s>>t>>l>>k;
    for(int i=1; i<=m; i++)
        cin>>s2>>s3>>s4,v[s2].pb({s3,s4}),v[s3].pb({s2,s4});
    for(int i=1; i<=n; i++)
        a[i]=-1,b[i]=-1;
    dist(s,a);
    dist(t,b);
    for(int i=1; i<=n; i++)
    {
        if(a[i]==-1)
            a[i]=inf;
        if(b[i]==-1) b[i]=inf;
    }
    if(a[t]<=k)
    {
        cout<<n*(n-1)/2;
    }
    else
    {
                sort(b+1,b+1+n);

        for(int i=1; i<=n; i++)
        {
             if(a[i]==inf) continue;
            s3=k-a[i]-l;
            s4=upper_bound(b,b+1+n,s3)-b-1;
            s5=s5+max(0ll,s4);
        }
        cout<<s5;
    }
}

Compilation message

Main.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main()
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 3 ms 5068 KB Output is correct
4 Correct 3 ms 4956 KB Output is correct
5 Correct 3 ms 5272 KB Output is correct
6 Correct 3 ms 5468 KB Output is correct
7 Correct 51 ms 21204 KB Output is correct
8 Correct 60 ms 21188 KB Output is correct
9 Correct 65 ms 24724 KB Output is correct
10 Correct 2 ms 4952 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 3 ms 5224 KB Output is correct
13 Correct 3 ms 5212 KB Output is correct
14 Correct 30 ms 14912 KB Output is correct
15 Correct 112 ms 22832 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 3 ms 5184 KB Output is correct
18 Correct 61 ms 20052 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 3 ms 5212 KB Output is correct
22 Correct 4 ms 5212 KB Output is correct
23 Correct 35 ms 14936 KB Output is correct
24 Correct 127 ms 22688 KB Output is correct
25 Correct 4 ms 4956 KB Output is correct
26 Correct 3 ms 5468 KB Output is correct
27 Correct 64 ms 27404 KB Output is correct
28 Correct 61 ms 20292 KB Output is correct
29 Correct 54 ms 17832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 5164 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 3 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4956 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 3 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 2 ms 4956 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 2 ms 4956 KB Output is correct
22 Correct 2 ms 4956 KB Output is correct
23 Correct 2 ms 5164 KB Output is correct
24 Correct 2 ms 4956 KB Output is correct
25 Correct 2 ms 4952 KB Output is correct
26 Correct 2 ms 4952 KB Output is correct
27 Correct 2 ms 4956 KB Output is correct
28 Correct 2 ms 4956 KB Output is correct
29 Correct 4 ms 4956 KB Output is correct
30 Correct 3 ms 4956 KB Output is correct
31 Correct 4 ms 4956 KB Output is correct
32 Correct 3 ms 5176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 5164 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 3 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4956 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 3 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 2 ms 4956 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 2 ms 4956 KB Output is correct
22 Correct 2 ms 4956 KB Output is correct
23 Correct 2 ms 5164 KB Output is correct
24 Correct 2 ms 4956 KB Output is correct
25 Correct 2 ms 4952 KB Output is correct
26 Correct 2 ms 4952 KB Output is correct
27 Correct 2 ms 4956 KB Output is correct
28 Correct 2 ms 4956 KB Output is correct
29 Correct 4 ms 4956 KB Output is correct
30 Correct 3 ms 4956 KB Output is correct
31 Correct 4 ms 4956 KB Output is correct
32 Correct 3 ms 5176 KB Output is correct
33 Correct 4 ms 5408 KB Output is correct
34 Correct 4 ms 5464 KB Output is correct
35 Correct 3 ms 5212 KB Output is correct
36 Correct 4 ms 5212 KB Output is correct
37 Correct 3 ms 5212 KB Output is correct
38 Correct 3 ms 5212 KB Output is correct
39 Correct 4 ms 5212 KB Output is correct
40 Correct 4 ms 5468 KB Output is correct
41 Correct 4 ms 5532 KB Output is correct
42 Correct 3 ms 5212 KB Output is correct
43 Correct 4 ms 5212 KB Output is correct
44 Correct 4 ms 5212 KB Output is correct
45 Correct 4 ms 5468 KB Output is correct
46 Correct 5 ms 5212 KB Output is correct
47 Correct 4 ms 5176 KB Output is correct
48 Correct 3 ms 5172 KB Output is correct
49 Correct 4 ms 5468 KB Output is correct
50 Correct 3 ms 5212 KB Output is correct
51 Correct 5 ms 5436 KB Output is correct
52 Correct 4 ms 5432 KB Output is correct
53 Correct 4 ms 5424 KB Output is correct
54 Correct 4 ms 5468 KB Output is correct
55 Correct 4 ms 5272 KB Output is correct
56 Correct 3 ms 5432 KB Output is correct
57 Correct 4 ms 5256 KB Output is correct
58 Correct 4 ms 5212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 3 ms 5068 KB Output is correct
4 Correct 3 ms 4956 KB Output is correct
5 Correct 3 ms 5272 KB Output is correct
6 Correct 3 ms 5468 KB Output is correct
7 Correct 51 ms 21204 KB Output is correct
8 Correct 60 ms 21188 KB Output is correct
9 Correct 65 ms 24724 KB Output is correct
10 Correct 2 ms 4952 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 3 ms 5224 KB Output is correct
13 Correct 3 ms 5212 KB Output is correct
14 Correct 30 ms 14912 KB Output is correct
15 Correct 112 ms 22832 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 3 ms 5184 KB Output is correct
18 Correct 61 ms 20052 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 3 ms 5212 KB Output is correct
22 Correct 4 ms 5212 KB Output is correct
23 Correct 35 ms 14936 KB Output is correct
24 Correct 127 ms 22688 KB Output is correct
25 Correct 4 ms 4956 KB Output is correct
26 Correct 3 ms 5468 KB Output is correct
27 Correct 64 ms 27404 KB Output is correct
28 Correct 61 ms 20292 KB Output is correct
29 Correct 54 ms 17832 KB Output is correct
30 Correct 2 ms 4956 KB Output is correct
31 Correct 2 ms 4956 KB Output is correct
32 Correct 2 ms 4956 KB Output is correct
33 Correct 2 ms 5164 KB Output is correct
34 Correct 2 ms 4956 KB Output is correct
35 Correct 2 ms 4956 KB Output is correct
36 Correct 2 ms 4956 KB Output is correct
37 Correct 2 ms 4956 KB Output is correct
38 Correct 2 ms 4956 KB Output is correct
39 Correct 3 ms 4956 KB Output is correct
40 Correct 2 ms 4956 KB Output is correct
41 Correct 2 ms 4956 KB Output is correct
42 Correct 2 ms 4956 KB Output is correct
43 Correct 2 ms 4956 KB Output is correct
44 Correct 3 ms 4956 KB Output is correct
45 Correct 2 ms 4956 KB Output is correct
46 Correct 2 ms 4956 KB Output is correct
47 Correct 2 ms 4956 KB Output is correct
48 Correct 2 ms 4956 KB Output is correct
49 Correct 2 ms 4956 KB Output is correct
50 Correct 2 ms 4956 KB Output is correct
51 Correct 2 ms 4956 KB Output is correct
52 Correct 2 ms 5164 KB Output is correct
53 Correct 2 ms 4956 KB Output is correct
54 Correct 2 ms 4952 KB Output is correct
55 Correct 2 ms 4952 KB Output is correct
56 Correct 2 ms 4956 KB Output is correct
57 Correct 2 ms 4956 KB Output is correct
58 Correct 4 ms 4956 KB Output is correct
59 Correct 3 ms 4956 KB Output is correct
60 Correct 4 ms 4956 KB Output is correct
61 Correct 3 ms 5176 KB Output is correct
62 Correct 4 ms 5408 KB Output is correct
63 Correct 4 ms 5464 KB Output is correct
64 Correct 3 ms 5212 KB Output is correct
65 Correct 4 ms 5212 KB Output is correct
66 Correct 3 ms 5212 KB Output is correct
67 Correct 3 ms 5212 KB Output is correct
68 Correct 4 ms 5212 KB Output is correct
69 Correct 4 ms 5468 KB Output is correct
70 Correct 4 ms 5532 KB Output is correct
71 Correct 3 ms 5212 KB Output is correct
72 Correct 4 ms 5212 KB Output is correct
73 Correct 4 ms 5212 KB Output is correct
74 Correct 4 ms 5468 KB Output is correct
75 Correct 5 ms 5212 KB Output is correct
76 Correct 4 ms 5176 KB Output is correct
77 Correct 3 ms 5172 KB Output is correct
78 Correct 4 ms 5468 KB Output is correct
79 Correct 3 ms 5212 KB Output is correct
80 Correct 5 ms 5436 KB Output is correct
81 Correct 4 ms 5432 KB Output is correct
82 Correct 4 ms 5424 KB Output is correct
83 Correct 4 ms 5468 KB Output is correct
84 Correct 4 ms 5272 KB Output is correct
85 Correct 3 ms 5432 KB Output is correct
86 Correct 4 ms 5256 KB Output is correct
87 Correct 4 ms 5212 KB Output is correct
88 Correct 86 ms 22868 KB Output is correct
89 Correct 100 ms 22976 KB Output is correct
90 Correct 86 ms 22764 KB Output is correct
91 Correct 101 ms 25992 KB Output is correct
92 Correct 103 ms 26016 KB Output is correct
93 Correct 44 ms 15696 KB Output is correct
94 Correct 38 ms 15696 KB Output is correct
95 Correct 153 ms 24764 KB Output is correct
96 Correct 141 ms 24660 KB Output is correct
97 Correct 181 ms 23084 KB Output is correct
98 Correct 149 ms 22896 KB Output is correct
99 Correct 69 ms 22096 KB Output is correct
100 Correct 81 ms 21876 KB Output is correct
101 Correct 100 ms 25912 KB Output is correct
102 Correct 104 ms 26060 KB Output is correct
103 Correct 38 ms 15632 KB Output is correct
104 Correct 36 ms 15820 KB Output is correct
105 Correct 170 ms 24812 KB Output is correct
106 Correct 167 ms 24668 KB Output is correct
107 Correct 140 ms 29176 KB Output is correct
108 Correct 150 ms 29428 KB Output is correct
109 Correct 77 ms 24204 KB Output is correct
110 Correct 89 ms 24080 KB Output is correct
111 Correct 79 ms 19432 KB Output is correct
112 Correct 79 ms 19420 KB Output is correct