제출 #1130102

#제출 시각아이디문제언어결과실행 시간메모리
1130102agrim_09Olympic Bus (JOI20_ho_t4)C++20
0 / 100
29 ms4164 KiB
// #pragma GCC optimize("O3,unroll-loops") // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define endl '\n'; #define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define py cout << "YES" << endl; #define pn cout << "NO" << endl; #define pb push_back #define int long long typedef long double lld; #define double lld typedef long long ll; typedef unsigned long long ull; const ll inf = 1e18; const ll mod = 1e9+7; const int N = 2e5; vector<int>primes = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97}; // Check for queue, priorioty_queue, stack, ordered_set solutions // stack => LIFO (whatever goes in last comes out last) // queue => FIFO (whatever goes in first comes out first) // priority_queue => Dynamic queries of minimum/maximum // ordered_set => set in vector form //[order_of_key(k) gives number of elements less than k, while find_by_order(i) gives i^th element] // To comment multiple lines : ctrl + / // To find and replace : ctrl+H void judge(){ srand(time(NULL)); #ifndef ONLINE_JUDGE freopen("inputB.txt","r",stdin); freopen("outputB.txt","w",stdout); freopen("Error.txt", "w", stderr); #define debug(x...) cerr << #x <<" = "; _print(x); cerr << endl; #else #define debug(x...) #endif } void usaco(string s) { freopen((s + ".in").c_str(),"r",stdin); freopen((s + ".out").c_str(),"w",stdout); } int dijkstra(vector<set<pair<int,ll>>>&adj, vector<int>src){ int n = adj.size(); vector<ll>dist(n,inf); priority_queue<pair<ll,int>>pq; for(auto source : src){ dist[source] = 0; pq.push({0,source}); } while(!pq.empty()){ auto x = pq.top(); ll d = -1*x.first; int node = x.second; pq.pop(); if(d!=dist[node]){ continue; } for(auto child : adj[node]){ int v = child.first; ll w = child.second; if((d+w)<dist[v]){ dist[v] = d+w; pq.push({-1*(d+w),v}); } } } return dist[0]+dist[n-1]; } void dfs(int node, vector<set<int>>&adj, vector<bool>&vis){ vis[node] = true; for(auto child : adj[node]){ if(!vis[child]){ dfs(child,adj,vis); } } } signed main(){ fastio; //judge(); int n,m; cin >> n >> m; int cost[n][n]; vector<set<int>>adj(n); for(int i = 0;i<n;i++){ for(int j = 0;j<n;j++){ cost[i][j] = 0; } } vector<vector<int>>type(m); for(int i = 0,u,v,c,d;i<m;i++){ cin >> u >> v >> c >> d; u--; v--; type[i] = {d,u,v}; cost[u][v]++; adj[u].insert(v); } sort(type.begin(),type.end()); vector<bool>vis1(n,false),vis2(n,false); dfs(0,adj,vis1); dfs(n-1,adj,vis2); if(vis1[n-1] and vis2[0]){ cout << 0; return 0; } for(int i = 0;i<m;i++){ int u = type[i][1], v = type[i][2]; fill(vis1.begin(),vis1.end(),false); fill(vis2.begin(),vis2.end(),false); if(cost[u][v]==1){ adj[u].erase(adj[u].find(v)); if(cost[v][u]==0){ adj[v].insert(u); dfs(0,adj,vis1); dfs(n-1,adj,vis2); if(vis1[n-1] and vis2[0]){ cout << type[i][0]; return 0; } adj[v].erase(adj[v].find(u)); } else{ continue; } adj[u].insert(v); } else{ if(cost[v][u]==0){ adj[v].insert(u); dfs(0,adj,vis1); dfs(n-1,adj,vis2); if(vis1[n-1] and vis2[0]){ cout << type[i][0]; return 0; } adj[v].erase(adj[v].find(u)); } } } }

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

ho_t4.cpp: In function 'void judge()':
ho_t4.cpp:37:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     freopen("inputB.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ho_t4.cpp:38:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     freopen("outputB.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t4.cpp:39:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     freopen("Error.txt", "w", stderr);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t4.cpp: In function 'void usaco(std::string)':
ho_t4.cpp:47:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |     freopen((s + ".in").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t4.cpp:48:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |     freopen((s + ".out").c_str(),"w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...