답안 #66798

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66798 2018-08-12T10:25:53 Z MrTEK Commuter Pass (JOI18_commuter_pass) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
#define mp make_pair
#define pb push_back
#define len(a) (int)a.size()
#define fi first
#define sc second
#define d1(w) cerr<<#w<<":"<<w<<endl;
#define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl;
#define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl;
#define left ind+ind
#define right ind+ind+1
#define mid (l+r)/2
#define FAST_IO ios_base::sync_with_stdio(false);
#define endl '\n'
#define int long long;
typedef long long int ll;

const int maxn = 620;
const long long LINF = 1e18;
const int LOG = 31;
const int INF = 1e9;
const int N = 1e5 + 5;
const int M = 1e4 + 5;
const int SQ = 350;
const int MOD = 998244353;

typedef pair <int,int> pii;

struct comp_node {
	int cur;
	long long cost,mnu,mnv;
};

bool operator < (comp_node x,comp_node y) {
	return x.cost > y.cost;
}
struct node {
	int cur;
	long long cost;
};

bool operator < (node x,node y) {
	return x.cost > y.cost;
}

priority_queue <node> Q;
priority_queue <comp_node> CQ;

vector <pair <int,int> > ed[N];

int n,m,s,t,u,v;
long long sp,cu[N],cv[N],ans = LINF,vis[N];

void sp_s(){
	for (int i = 1 ; i <= n ; i++) vis[i] = LINF;
	CQ.push({s,0,cu[s],cv[s]});
	while(len(CQ)) {
		auto temp = CQ.top();
		CQ.pop();
		int cur = temp.cur;
		long long cost = temp.cost,mnu = temp.mnu,mnv = temp.mnv;
		if (vis[cur] < cost || (vis[cur] == cost && cur != t)) continue;
		vis[cur] = cost;
		if (cur == t) ans = min(ans,mnu + mnv);
		for (auto i : ed[cur]) CQ.push({i.fi,cost + i.sc,min(mnu,cu[i.fi]),min(mnv,cv[i.fi])});
	}
	while(len(CQ)) CQ.pop();
	memset(vis,0,sizeof vis);	
}

void sp_u(){
	Q.push({u,0});
	while(len(Q)) {
		auto temp = Q.top();
		Q.pop();
		int cur = temp.cur;
		long long cost = temp.cost;
		if (vis[cur]) continue;
		vis[cur] = 1;
		cu[cur] = cost;
		for (auto i : ed[cur]) Q.push({i.fi,cost + i.sc});
	}
	memset(vis,0,sizeof vis);
	while(len(Q)) Q.pop();
}

void sp_v(){
	Q.push({v,0});
	while(len(Q)) {
		auto temp = Q.top();
		Q.pop();
		int cur = temp.cur;
		long long cost = temp.cost;
		if (vis[cur]) continue;
		vis[cur] = 1;
		cv[cur] = cost;
		for (auto i : ed[cur]) Q.push({i.fi,cost + i.sc});
	}
	memset(vis,0,sizeof vis);
	while(len(Q)) Q.pop();
}

main() {

	scanf("%lld %lld %lld %lld %lld %lld",&n,&m,&s,&t,&u,&v);
	for (int i = 1 ; i <= m ; i++) {
		int u,v,c;
		scanf("%lld %lld %lld",&u,&v,&c);
		ed[u].pb(mp(v,c));
		ed[v].pb(mp(u,c));
	}
	sp_u();
	sp_v();
	sp_s();
	printf("%lld\n",min(ans,cu[v]));
}

Compilation message

commuter_pass.cpp:17:13: error: 'long long long' is too long for GCC
 #define int long long;
             ^
commuter_pass.cpp:18:19: note: in expansion of macro 'int'
 typedef long long int ll;
                   ^~~
commuter_pass.cpp:17:18: error: 'long long long' is too long for GCC
 #define int long long;
                  ^
commuter_pass.cpp:18:19: note: in expansion of macro 'int'
 typedef long long int ll;
                   ^~~
commuter_pass.cpp:17:18: error: declaration does not declare anything [-fpermissive]
 #define int long long;
                  ^
commuter_pass.cpp:18:19: note: in expansion of macro 'int'
 typedef long long int ll;
                   ^~~
commuter_pass.cpp:18:23: error: 'll' does not name a type
 typedef long long int ll;
                       ^~
commuter_pass.cpp:17:18: error: declaration does not declare anything [-fpermissive]
 #define int long long;
                  ^
commuter_pass.cpp:20:7: note: in expansion of macro 'int'
 const int maxn = 620;
       ^~~
commuter_pass.cpp:20:11: error: 'maxn' does not name a type; did you mean 'tan'?
 const int maxn = 620;
           ^~~~
           tan
commuter_pass.cpp:17:18: error: declaration does not declare anything [-fpermissive]
 #define int long long;
                  ^
commuter_pass.cpp:22:7: note: in expansion of macro 'int'
 const int LOG = 31;
       ^~~
commuter_pass.cpp:22:11: error: 'LOG' does not name a type
 const int LOG = 31;
           ^~~
commuter_pass.cpp:17:18: error: declaration does not declare anything [-fpermissive]
 #define int long long;
                  ^
commuter_pass.cpp:23:7: note: in expansion of macro 'int'
 const int INF = 1e9;
       ^~~
commuter_pass.cpp:23:11: error: 'INF' does not name a type; did you mean 'LINF'?
 const int INF = 1e9;
           ^~~
           LINF
commuter_pass.cpp:17:18: error: declaration does not declare anything [-fpermissive]
 #define int long long;
                  ^
commuter_pass.cpp:24:7: note: in expansion of macro 'int'
 const int N = 1e5 + 5;
       ^~~
commuter_pass.cpp:24:11: error: 'N' does not name a type
 const int N = 1e5 + 5;
           ^
commuter_pass.cpp:17:18: error: declaration does not declare anything [-fpermissive]
 #define int long long;
                  ^
commuter_pass.cpp:25:7: note: in expansion of macro 'int'
 const int M = 1e4 + 5;
       ^~~
commuter_pass.cpp:25:11: error: 'M' does not name a type
 const int M = 1e4 + 5;
           ^
commuter_pass.cpp:17:18: error: declaration does not declare anything [-fpermissive]
 #define int long long;
                  ^
commuter_pass.cpp:26:7: note: in expansion of macro 'int'
 const int SQ = 350;
       ^~~
commuter_pass.cpp:26:11: error: 'SQ' does not name a type
 const int SQ = 350;
           ^~
commuter_pass.cpp:17:18: error: declaration does not declare anything [-fpermissive]
 #define int long long;
                  ^
commuter_pass.cpp:27:7: note: in expansion of macro 'int'
 const int MOD = 998244353;
       ^~~
commuter_pass.cpp:27:11: error: 'MOD' does not name a type
 const int MOD = 998244353;
           ^~~
commuter_pass.cpp:17:18: error: wrong number of template arguments (1, should be 2)
 #define int long long;
                  ^
commuter_pass.cpp:29:15: note: in expansion of macro 'int'
 typedef pair <int,int> pii;
               ^~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from commuter_pass.cpp:1:
/usr/include/c++/7/bits/stl_pair.h:198:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
     struct pair
            ^~~~
commuter_pass.cpp:29:1: warning: 'typedef' was ignored in this declaration
 typedef pair <int,int> pii;
 ^~~~~~~
commuter_pass.cpp:29:18: error: expected unqualified-id before ',' token
 typedef pair <int,int> pii;
                  ^
commuter_pass.cpp:17:13: error: expected unqualified-id before 'long'
 #define int long long;
             ^
commuter_pass.cpp:29:19: note: in expansion of macro 'int'
 typedef pair <int,int> pii;
                   ^~~
commuter_pass.cpp:29:22: error: expected unqualified-id before '>' token
 typedef pair <int,int> pii;
                      ^
commuter_pass.cpp:17:18: error: declaration does not declare anything [-fpermissive]
 #define int long long;
                  ^
commuter_pass.cpp:32:2: note: in expansion of macro 'int'
  int cur;
  ^~~
commuter_pass.cpp:32:6: error: 'cur' does not name a type
  int cur;
      ^~~
commuter_pass.cpp:17:18: error: declaration does not declare anything [-fpermissive]
 #define int long long;
                  ^
commuter_pass.cpp:40:2: note: in expansion of macro 'int'
  int cur;
  ^~~
commuter_pass.cpp:40:6: error: 'cur' does not name a type
  int cur;
      ^~~
commuter_pass.cpp:17:18: error: wrong number of template arguments (1, should be 2)
 #define int long long;
                  ^
commuter_pass.cpp:51:15: note: in expansion of macro 'int'
 vector <pair <int,int> > ed[N];
               ^~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from commuter_pass.cpp:1:
/usr/include/c++/7/bits/stl_pair.h:198:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
     struct pair
            ^~~~
commuter_pass.cpp:51:9: error: template argument 1 is invalid
 vector <pair <int,int> > ed[N];
         ^
commuter_pass.cpp:51:9: error: template argument 2 is invalid
commuter_pass.cpp:51:18: error: expected unqualified-id before ',' token
 vector <pair <int,int> > ed[N];
                  ^
commuter_pass.cpp:17:13: error: expected unqualified-id before 'long'
 #define int long long;
             ^
commuter_pass.cpp:51:19: note: in expansion of macro 'int'
 vector <pair <int,int> > ed[N];
                   ^~~
commuter_pass.cpp:51:22: error: expected unqualified-id before '>' token
 vector <pair <int,int> > ed[N];
                      ^
commuter_pass.cpp:17:18: error: declaration does not declare anything [-fpermissive]
 #define int long long;
                  ^
commuter_pass.cpp:53:1: note: in expansion of macro 'int'
 int n,m,s,t,u,v;
 ^~~
commuter_pass.cpp:53:5: error: 'n' does not name a type
 int n,m,s,t,u,v;
     ^
commuter_pass.cpp:54:17: error: 'N' was not declared in this scope
 long long sp,cu[N],cv[N],ans = LINF,vis[N];
                 ^
commuter_pass.cpp:54:23: error: 'N' was not declared in this scope
 long long sp,cu[N],cv[N],ans = LINF,vis[N];
                       ^
commuter_pass.cpp:54:41: error: 'N' was not declared in this scope
 long long sp,cu[N],cv[N],ans = LINF,vis[N];
                                         ^
commuter_pass.cpp: In function 'void sp_s()':
commuter_pass.cpp:17:18: error: declaration does not declare anything [-fpermissive]
 #define int long long;
                  ^
commuter_pass.cpp:57:7: note: in expansion of macro 'int'
  for (int i = 1 ; i <= n ; i++) vis[i] = LINF;
       ^~~
commuter_pass.cpp:57:11: error: 'i' was not declared in this scope
  for (int i = 1 ; i <= n ; i++) vis[i] = LINF;
           ^
commuter_pass.cpp:57:24: error: 'n' was not declared in this scope
  for (int i = 1 ; i <= n ; i++) vis[i] = LINF;
                        ^
commuter_pass.cpp:57:26: error: expected ')' before ';' token
  for (int i = 1 ; i <= n ; i++) vis[i] = LINF;
                          ^
commuter_pass.cpp:57:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for (int i = 1 ; i <= n ; i++) vis[i] = LINF;
  ^~~
commuter_pass.cpp:57:28: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for (int i = 1 ; i <= n ; i++) vis[i] = LINF;
                            ^
commuter_pass.cpp:57:28: error: 'i' was not declared in this scope
commuter_pass.cpp:58:11: error: 's' was not declared in this scope
  CQ.push({s,0,cu[s],cv[s]});
           ^
commuter_pass.cpp:58:11: note: suggested alternative: 'sp'
  CQ.push({s,0,cu[s],cv[s]});
           ^
           sp
commuter_pass.cpp:58:15: error: 'cu' was not declared in this scope
  CQ.push({s,0,cu[s],cv[s]});
               ^~
commuter_pass.cpp:58:21: error: 'cv' was not declared in this scope
  CQ.push({s,0,cu[s],cv[s]});
                     ^~
commuter_pass.cpp:58:27: error: no matching function for call to 'std::priority_queue<comp_node>::push(<brace-enclosed initializer list>)'
  CQ.push({s,0,cu[s],cv[s]});
                           ^
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from commuter_pass.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:595:7: note: candidate: void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = comp_node; _Sequence = std::vector<comp_node, std::allocator<comp_node> >; _Compare = std::less<comp_node>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = comp_node]
       push(const value_type& __x)
       ^~~~
/usr/include/c++/7/bits/stl_queue.h:595:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const comp_node&}'
/usr/include/c++/7/bits/stl_queue.h:603:7: note: candidate: void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = comp_node; _Sequence = std::vector<comp_node, std::allocator<comp_node> >; _Compare = std::less<comp_node>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = comp_node]
       push(value_type&& __x)
       ^~~~
/usr/include/c++/7/bits/stl_queue.h:603:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<comp_node>::value_type&& {aka comp_node&&}'
commuter_pass.cpp:17:13: error: expected primary-expression before 'long'
 #define int long long;
             ^
commuter_pass.cpp:6:17: note: in expansion of macro 'int'
 #define len(a) (int)a.size()
                 ^~~
commuter_pass.cpp:59:8: note: in expansion of macro 'len'
  while(len(CQ)) {
        ^~~
commuter_pass.cpp:17:13: error: expected ')' before 'long'
 #define int long long;
             ^
commuter_pass.cpp:6:17: note: in expansion of macro 'int'
 #define len(a) (int)a.size()
                 ^~~
commuter_pass.cpp:59:8: note: in expansion of macro 'len'
  while(len(CQ)) {
        ^~~
commuter_pass.cpp:17:22: error: expected ')' before ';' token
 #define int long long;
                      ^
commuter_pass.cpp:6:17: note: in expansion of macro 'int'
 #define len(a) (int)a.size()
                 ^~~
commuter_pass.cpp:59:8: note: in expansion of macro 'len'
  while(len(CQ)) {
        ^~~
commuter_pass.cpp:6:20: error: expected primary-expression before ')' token
 #define len(a) (int)a.size()
                    ^
commuter_pass.cpp:59:8: note: in expansion of macro 'len'
  while(len(CQ)) {
        ^~~
commuter_pass.cpp:17:13: error: expected primary-expression before 'long'
 #define int long long;
             ^
commuter_pass.cpp:6:17: note: in expansion of macro 'int'
 #define len(a) (int)a.size()
                 ^~~
commuter_pass.cpp:69:8: note: in expansion of macro 'len'
  while(len(CQ)) CQ.pop();
        ^~~
commuter_pass.cpp:17:13: error: expected ')' before 'long'
 #define int long long;
             ^
commuter_pass.cpp:6:17: note: in expansion of macro 'int'
 #define len(a) (int)a.size()
                 ^~~
commuter_pass.cpp:69:8: note: in expansion of macro 'len'
  while(len(CQ)) CQ.pop();
        ^~~
commuter_pass.cpp:17:22: error: expected ')' before ';' token
 #define int long long;
                      ^
commuter_pass.cpp:6:17: note: in expansion of macro 'int'
 #define len(a) (int)a.size()
                 ^~~
commuter_pass.cpp:69:8: note: in expansion of macro 'len'
  while(len(CQ)) CQ.pop();
        ^~~
commuter_pass.cpp:6:20: error: expected primary-expression before ')' token
 #define len(a) (int)a.size()
                    ^
commuter_pass.cpp:69:8: note: in expansion of macro 'len'
  while(len(CQ)) CQ.pop();
        ^~~
commuter_pass.cpp:70:9: error: 'vis' was not declared in this scope
  memset(vis,0,sizeof vis); 
         ^~~
commuter_pass.cpp: In function 'void sp_u()':
commuter_pass.cpp:74:10: error: 'u' was not declared in this scope
  Q.push({u,0});
          ^
commuter_pass.cpp:74:14: error: no matching function for call to 'std::priority_queue<node>::push(<brace-enclosed initializer list>)'
  Q.push({u,0});
              ^
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from commuter_pass.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:595:7: note: candidate: void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = node; _Sequence = std::vector<node, std::allocator<node> >; _Compare = std::less<node>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = node]
       push(const value_type& __x)
       ^~~~
/usr/include/c++/7/bits/stl_queue.h:595:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const node&}'
/usr/include/c++/7/bits/stl_queue.h:603:7: note: candidate: void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = node; _Sequence = std::vector<node, std::allocator<node> >; _Compare = std::less<node>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = node]
       push(value_type&& __x)
       ^~~~
/usr/include/c++/7/bits/stl_queue.h:603:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<node>::value_type&& {aka node&&}'
commuter_pass.cpp:17:13: error: expected primary-expression before 'long'
 #define int long long;
             ^
commuter_pass.cpp:6:17: note: in expansion of macro 'int'
 #define len(a) (int)a.size()
                 ^~~
commuter_pass.cpp:75:8: note: in expansion of macro 'len'
  while(len(Q)) {
        ^~~
commuter_pass.cpp:17:13: error: expected ')' before 'long'
 #define int long long;
             ^
commuter_pass.cpp:6:17: note: in expansion of macro 'int'
 #define len(a) (int)a.size()
                 ^~~
commuter_pass.cpp:75:8: note: in expansion of macro 'len'
  while(len(Q)) {
        ^~~
commuter_pass.cpp:17:22: error: expected ')' before ';' token
 #define int long long;
                      ^
commuter_pass.cpp:6:17: note: in expansion of macro 'int'
 #define len(a) (int)a.size()
                 ^~~
commuter_pass.cpp:75:8: note: in expansion of macro 'len'
  while(len(Q)) {
        ^~~
commuter_pass.cpp:6:20: error: expected primary-expression before ')' token
 #define len(a) (int)a.size()
                    ^
commuter_pass.cpp:75:8: note: in expansion of macro 'len'
  while(len(Q)) {
        ^~~
commuter_pass.cpp:85:9: error: 'vis' was not declared in this scope
  memset(vis,0,sizeof vis);
         ^~~
commuter_pass.cpp:17:13: error: expected primary-expression before 'long'
 #define int long long;
             ^
commuter_pass.cpp:6:17: note: in expansion of macro 'int'
 #define len(a) (int)a.size()
                 ^~~
commuter_pass.cpp:86:8: note: in expansion of macro 'len'
  while(len(Q)) Q.pop();
        ^~~
commuter_pass.cpp:17:13: error: expected ')' before 'long'
 #define int long long;
             ^
commuter_pass.cpp:6:17: note: in expansion of macro 'int'
 #define len(a) (int)a.size()
                 ^~~
commuter_pass.cpp:86:8: note: in expansion of macro 'len'
  while(len(Q)) Q.pop();
        ^~~
commuter_pass.cpp:17:22: error: expected ')' before ';' token
 #define int long long;
                      ^
commuter_pass.cpp:6:17: note: in expansion of macro 'int'
 #define len(a) (int)a.size()
                 ^~~
commuter_pass.cpp:86:8: note: in expansion of macro 'len'
  while(len(Q)) Q.pop();
        ^~~
commuter_pass.cpp:6:20: error: expected primary-expression before ')' token
 #define len(a) (int)a.size()
                    ^
commuter_pass.cpp:86:8: note: in expansion of macro 'len'
  while(len(Q)) Q.pop();
        ^~~
commuter_pass.cpp: In function 'void sp_v()':
commuter_pass.cpp:90:10: error: 'v' was not declared in this scope
  Q.push({v,0});
          ^
commuter_pass.cpp:90:14: error: no matching function for call to 'std::priority_queue<node>::push(<brace-enclosed initializer list>)'
  Q.push({v,0});
              ^
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_6