# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
284331 |
2020-08-27T08:50:38 Z |
임성재(#5754) |
Aesthetic (NOI20_aesthetic) |
C++17 |
|
393 ms |
39068 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;
dp[x] = d[x];
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);
}
}
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 ? 1 : 0);
}
# |
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 |
380 ms |
33272 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
393 ms |
33740 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
357 ms |
39068 KB |
Output is correct |
2 |
Incorrect |
160 ms |
30840 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
357 ms |
39068 KB |
Output is correct |
2 |
Incorrect |
160 ms |
30840 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 |
- |