제출 #718089

#제출 시각아이디문제언어결과실행 시간메모리
718089KalashnikovRobot (JOI21_ho_t4)C++17
0 / 100
502 ms50932 KiB
#include <bits/stdc++.h> #define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout) #define all(a) a.begin() , a.end() #define F first #define S second using namespace std; using ll = long long; #define int ll const int N = 1e5+5 , inf = 2e9 + 7; const ll INF = 1e18 , mod = 1e9+7 , P = 6547; map<int,int> mp[N]; vector<pair<int,int>> g[N]; vector<int> cvet[N]; int from[N], how[N]; void solve(int tc) { int n, m; cin >> n >> m; vector<array<int,4>> vec; for(int i = 1; i <= m; i ++) { int a, b,c, p; cin >> a >> b >> c >> p; vec.push_back({a,b,c,p}); mp[a][c] ++; mp[b][c] ++; } for(auto [a,b,c,p]: vec) { if(mp[a][c] == 1) { g[a].push_back({b,0}); cvet[a].push_back(c); } else { g[a].push_back({b,p}); cvet[a].push_back(c); } if(mp[b][c] == 1) { g[b].push_back({a,0}); cvet[b].push_back(c); } else { g[b].push_back({a,p}); cvet[b].push_back(c); } } vector<ll> d(n+1, INF); d[1] = 0; set<pair<int,int>> st; st.insert({0, 1}); while(st.size()) { pair<int,int> cur = *st.begin(); st.erase(cur); int cnt = 0; for(auto to: g[cur.S]) { int CV = cvet[cur.S][cnt]; if(from[cur.S] == CV && how[cur.S] != 0 && mp[cur.S][CV] == 2) { to.S = 0; } if(cur.F + to.S < d[to.F]) { st.erase({d[to.F], to.F}); from[to.F] = CV; how[to.F] = to.S; d[to.F] = cur.F + to.S; st.insert({d[to.F], to.F}); } cnt ++; } } if(d[n] == INF) d[n] = -1; cout << d[n]; } /* */ main() { ios; int tt = 1 , tc = 0; // cin >> tt; while(tt --) { solve(++tc); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp:79:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   79 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...