제출 #754122

#제출 시각아이디문제언어결과실행 시간메모리
754122MarwenElarbi사이버랜드 (APIO23_cyberland)C++17
49 / 100
3079 ms48072 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include "cyberland.h" #define vi vector<int> #define ve vector #define ll long long #define vl vector<ll> #define vll vector<pair<ll,ll>> #define onbit __builtin_popcount #define ii pair<int,int> #define vvi vector<vi> #define vii vector<ii> #define gii greater<ii> #define pb push_back #define mp make_pair #define fi first #define se second #define INF 1e18 #define eps 1e-7 #define eps1 1e-2 #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define MAX_A 1e5+5 using namespace std; using namespace __gnu_pbds; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const ll MOD = 1e9+7; const int nax = 1e5+5; const int MAX_VAL = 1e6; double PI=3.14159265359; int arx[8]={1,1,0,-1,-1,-1, 0, 1}; int ary[8]={0,1,1, 1, 0,-1,-1,-1}; void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } vector<pair<int,double>> adj[nax]; int lst,cnt; vector<bool> vis(nax,0); double dis[nax][50]; void dfs(int x){ vis[x]=true; if (x==lst) return; for(auto u:adj[x]){ if (vis[u.fi]==true) continue; dfs(u.fi); } return; } double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) { lst=H; cnt=K; for (int i = 0; i < N; ++i) { adj[i].clear(); for (int j = 0; j <= cnt; ++j) { dis[i][j]=1e18; } vis[i]=false; } for (int i = 0; i < M; ++i) { adj[x[i]].pb({y[i],c[i]}); adj[y[i]].pb({x[i],c[i]}); } dfs(0); priority_queue<pair<double,pair<int,int>>,vector<pair<double,pair<int,int>>>,greater<>> pq; pq.push({0,{0,cnt}}); for (int i = 0; i < N; ++i) { if (arr[i]==0&&vis[i]==true) { pq.push({0,{i,cnt}}); for (int j = 0; j <= cnt; ++j) { dis[i][j]=0; } } } while(!pq.empty()){ int node=pq.top().se.fi; int lvl=pq.top().se.se; double distance=pq.top().fi; pq.pop(); if (node==lst){ return distance; } for(auto u:adj[node]){ double d=u.se+distance; if (arr[u.fi]<=1){ if (dis[u.fi][lvl]<=d) continue; dis[u.fi][lvl]=d; pq.push({d,{u.fi,lvl}}); }else{ if (dis[u.fi][lvl]>d){ dis[u.fi][lvl]=d; pq.push({d,{u.fi,lvl}}); } if (lvl==0) continue; if (dis[u.fi][lvl-1]>(d/2)){ dis[u.fi][lvl-1]=d/2; pq.push({d/2,{u.fi,lvl-1}}); } } } } return -1; } /*int main(){ optimise; #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int T; assert(1 == scanf("%d", &T)); while (T--){ int N,M,K,H; assert(4 == scanf("%d %d %d\n%d", &N, &M, &K, &H)); std::vector<int> x(M); std::vector<int> y(M); std::vector<int> c(M); std::vector<int> arr(N); for (int i=0;i<N;i++) assert(1 == scanf("%d", &arr[i])); for (int i=0;i<M;i++) assert(3 == scanf("%d %d %d", &x[i], &y[i], &c[i])); printf("%.12lf\n", solve(N, M, K, H, x, y, c, arr)); } }*/

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

cyberland.cpp: In function 'void setIO(std::string)':
cyberland.cpp:34:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cyberland.cpp:35:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |     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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...