# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
284324 |
2020-08-27T08:41:54 Z |
임성재(#5754) |
Aesthetic (NOI20_aesthetic) |
C++17 |
|
395 ms |
40664 KB |
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll, pll> plll;
const int inf = 1e9;
const ll INF = 1e18;
int n, m;
int u[300010];
int v[300010];
ll w[300010];
ll a[300010];
vector<pll> g[300010];
int dp[300010];
int d[300010];
bool chk[300010];
int ans = inf;
void dfs(int x, int p) {
chk[x] = true;
int mn = d[x];
dp[x] = inf;
for(auto i : g[x]) {
if(i.se == p) continue;
if(chk[i.fi]) {
dp[x] = min(dp[x], d[i.fi]);
continue;
}
d[i.fi] = d[x] + 1;
dfs(i.fi, i.se);
dp[x] = min(dp[x], dp[i.fi]);
}
if(p && dp[x] >= d[x]) {
ans = min(ans, p);
}
dp[x] = min(mn, dp[x]);
}
int main() {
fast;
cin >> n >> m;
for(int i=1; i<=m; i++) {
cin >> u[i] >> v[i] >> w[i];
g[u[i]].eb(v[i], i);
g[v[i]].eb(u[i], i);
}
for(int i=m; i > 1; i--) {
a[i-1] = max(a[i], w[i]);
}
dfs(1, 0);
memset(chk, 0, sizeof(chk));
queue<int> q;
q.em(1);
chk[1] = true;
while(q.size()) {
int x = q.front();
q.pop();
for(auto i : g[x]) {
if(chk[i.fi]) continue;
chk[i.fi] = true;
d[i.fi] = d[x] + 1;
q.em(i.fi);
}
}
cout << d[n] + (ans < m);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
7680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
7680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
395 ms |
33196 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
387 ms |
33748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
373 ms |
40664 KB |
Output is correct |
2 |
Incorrect |
155 ms |
30968 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
373 ms |
40664 KB |
Output is correct |
2 |
Incorrect |
155 ms |
30968 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
7680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |