답안 #426422

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
426422 2021-06-14T02:43:04 Z hibye1217 꿈 (IOI13_dreaming) C++17
컴파일 오류
0 ms 0 KB
#ifndef NOTSUBMIT
#include <bits/stdc++.h>
using namespace std;
#include "dreaming.h"
#endif // NOTSUBMIT

// Only Subtask 2
// Will do Subtask 1 later

typedef long long ll;
typedef pair<ll, ll> pl2;
vector<pl2> adj[100020];
int par[100020];

inline int fnd(int a){
	if (par[a] == a){ return a; }
	return par[a] = fnd(par[a]);
}

inline void uni(int a, int b){
	int pa = fnd(a), pb = fnd(b);
	par[pa] = pb;
}

bool chk[100020];
pl2 dfs(int st){
	stack<pl2> stk;
	memset(chk, 0, sizeof(chk));
	q.push({st, 0});
	pl2 res = {st, 0};
	while (!stk.empty()){
		int now = stk.top().fr; ll dst = stk.top().sc;
		if (res.sc < dst){ res = {now, dst}; }
		for (pl2 p : adj[now]){
			int nxt = p.fr; ll d = p.sc;
			if (chk[nxt]){ continue; }
			chk[nxt] = 1;
			stk.push({ nxt, dst+d });
		}
	}
	return res;
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
	for (int i = 0; i < M; i++){
		adj[ A[i] ].push_back({ B[i], T[i] });
		adj[ B[i] ].push_back({ A[i], T[i] });
		uni(A[i], B[i]);
	}
	if (m == n-2){
		if (n <= 100){ // Subtask 2
			ll ans = 1e12;
			for (int i = 0; i < N; i++){
				for (int j = 0; j < N; j++){
					if (fnd(i) == fnd(j)){ continue; }
					adj[i].push_back({j, L});
					adj[j].push_back({i, L});
					ans = min( ans, bfs( bfs(0).fr ).sc );
				}
			}
			return ans;
		}
		else{ // Subtask 1, Not Implemented Yet

		}
	}
	return -1;
}

Compilation message

dreaming.cpp: In function 'pl2 dfs(int)':
dreaming.cpp:29:2: error: 'q' was not declared in this scope
   29 |  q.push({st, 0});
      |  ^
dreaming.cpp:32:23: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'struct std::pair<long long int, long long int>'} has no member named 'fr'
   32 |   int now = stk.top().fr; ll dst = stk.top().sc;
      |                       ^~
dreaming.cpp:32:46: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'struct std::pair<long long int, long long int>'} has no member named 'sc'
   32 |   int now = stk.top().fr; ll dst = stk.top().sc;
      |                                              ^~
dreaming.cpp:33:11: error: 'pl2' {aka 'struct std::pair<long long int, long long int>'} has no member named 'sc'
   33 |   if (res.sc < dst){ res = {now, dst}; }
      |           ^~
dreaming.cpp:35:16: error: 'pl2' {aka 'struct std::pair<long long int, long long int>'} has no member named 'fr'
   35 |    int nxt = p.fr; ll d = p.sc;
      |                ^~
dreaming.cpp:35:29: error: 'pl2' {aka 'struct std::pair<long long int, long long int>'} has no member named 'sc'
   35 |    int nxt = p.fr; ll d = p.sc;
      |                             ^~
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:50:6: error: 'm' was not declared in this scope
   50 |  if (m == n-2){
      |      ^
dreaming.cpp:50:11: error: 'n' was not declared in this scope
   50 |  if (m == n-2){
      |           ^
dreaming.cpp:58:27: error: 'bfs' was not declared in this scope; did you mean 'dfs'?
   58 |      ans = min( ans, bfs( bfs(0).fr ).sc );
      |                           ^~~
      |                           dfs
dreaming.cpp:58:22: error: 'bfs' was not declared in this scope; did you mean 'dfs'?
   58 |      ans = min( ans, bfs( bfs(0).fr ).sc );
      |                      ^~~
      |                      dfs