답안 #848430

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
848430 2023-09-12T15:20:18 Z vjudge1 Robot (JOI21_ho_t4) C++14
컴파일 오류
0 ms 0 KB
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include<bitset>
//#include "supertrees.h"
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define pb push_back
#define all(x) x.begin(),x.end()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
#define int long long
const int mxn=1e5,mod=998244353,lg=20,root=80,inf=1e18;
void setIO(string name) {
	ios_base::sync_with_stdio(0); cin.tie(0);
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
map<int,int>mp[mxn+10];
map<int,int>mn[mxn+10];
vector<ppii>adj[mxn+10];
int dist[mxn+10];
bitset<mxn+10>vis;
int t[mxn+10];
int32_t main(){
    fastio
    int n,m;cin>>n>>m;
    for(int i=0;i<m;i++){
        int u,v,c,w;cin>>u>>v>>c>>w;
        adj[u].pb({v,{c,w}});
        adj[v].pb({u,{c,w}});
        mp[u][c]+=w;
        mp[v][c]+=w;
    }
    fill(dist,dist+n+1,inf);
    priority_queue<pii,vector<pii>,greater<pii>>pq;
    pq.push({0,1});
    dist[1]=0;
    pii tmp;
    while(!pq.empty()){
        int cur=pq.top().s;
        if(vis[cur]){
            pq.pop();
            continue;
        }
        vis[cur]=true;
        pq.pop();
        //cout<<cur<<'\n';
        for(auto i:adj[cur]){
            if(mn[i.f].find(i.s.f)==mn[i.f].end())mn[i.f][i.s.f]=dist[cur];
            int cost=dist[cur];
            if(mn[cur].find(i.s.f)!=mn[cur].end())cost=mn[cur][i.s.f];
            cost+=(mp[cur][i.s.f]-i.s.s);
            cost=min(cost,dist[cur]+i.s.s);
            if(dist[i.f]>cost){
                dist[i.f]=cost;
                pq.push({dist[i.f],i.f});
            }
        }
    }
    cout<<((dist[n]==inf)?-1:dist[n]);
    return 0;
}

Compilation message

Main.cpp: In function 'void setIO(std::string)':
Main.cpp:30:12: error: incomplete type 'std::ios_base' used in nested name specifier
   30 |  ios_base::sync_with_stdio(0); cin.tie(0);
      |            ^~~~~~~~~~~~~~~
Main.cpp:30:32: error: 'cin' was not declared in this scope
   30 |  ios_base::sync_with_stdio(0); cin.tie(0);
      |                                ^~~
Main.cpp:13:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
   12 | #include<bitset>
  +++ |+#include <iostream>
   13 | //#include "supertrees.h"
Main.cpp: In function 'int32_t main()':
Main.cpp:25:21: error: incomplete type 'std::ios' {aka 'std::basic_ios<char>'} used in nested name specifier
   25 | #define fastio ios::sync_with_stdio(false);cin.tie(NULL);
      |                     ^~~~~~~~~~~~~~~
Main.cpp:41:5: note: in expansion of macro 'fastio'
   41 |     fastio
      |     ^~~~~~
Main.cpp:25:44: error: 'cin' was not declared in this scope
   25 | #define fastio ios::sync_with_stdio(false);cin.tie(NULL);
      |                                            ^~~
Main.cpp:41:5: note: in expansion of macro 'fastio'
   41 |     fastio
      |     ^~~~~~
Main.cpp:25:44: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
   25 | #define fastio ios::sync_with_stdio(false);cin.tie(NULL);
      |                                            ^~~
Main.cpp:41:5: note: in expansion of macro 'fastio'
   41 |     fastio
      |     ^~~~~~
Main.cpp:76:5: error: 'cout' was not declared in this scope
   76 |     cout<<((dist[n]==inf)?-1:dist[n]);
      |     ^~~~
Main.cpp:76:5: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
Main.cpp: In function 'void setIO(std::string)':
Main.cpp:31:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:32:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~