Submission #122439

# Submission time Handle Problem Language Result Execution time Memory
122439 2019-06-28T08:21:22 Z 김세빈(#2988) Toll (APIO13_toll) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;

struct edge{
	int u, v, c, t;
	edge() {}
	edge(int u, int v, int c, int t) :
		u(u), v(v), c(c), t(t) {}
};

vector <pii> T[11];
vector <edge> E;
int P[11], C[11], X[11];
int n, m, k, x, ans;

int find(int p) { return p == P[p]? p : P[p] = find(P[p]); }

int dfs(int p, int r)
{
	int ret = X[p];
	
	for(pii &t: T[p]){
		if(t.first != r){
			if(t.second) x = dfs(t.first, p);
			else ret += dfs(t.first, p);
		}
	}
	
	return ret;
}

int main()
{
	int i, j, u, v, c;
	
	scanf("%d%d%d", &n, &m, &k);
	
	if(n > 10) return 0;
	
	for(i=0; i<m; i++){
		scanf("%d%d%d", &u, &v, C + i);
		E.emplace_back(u, v, C[i], 0);s
	}
	
	scanf("%d%d", &u, &v);
	E.emplace_back(u, v, 0, 1);
	
	for(i=1; i<=n; i++){
		scanf("%d", X + i);
	}
	
	for(i=0; i<m; i++){
		for(edge &e: E){
			if(e.t == 1) e.c = C[i];
		}
		
		sort(E.begin(), E.end(), [&](edge &ea, edge &eb){
			if(ea.c != eb.c) return ea.c < eb.c;
			else return ea.t > eb.t;
		});
		
		for(j=1; j<=n; j++){
			P[j] = j;
			T[j].clear();
		}
		
		for(edge &e: E){
			if(find(e.u) != find(e.v)){
				P[find(e.u)] = find(e.v);
				T[e.u].emplace_back(e.v, e.t);
				T[e.v].emplace_back(e.u, e.t);
			}
		}
		
		x = 0; dfs(1, 0);
		ans = max(ans, x * C[i]);
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Compilation message

toll.cpp: In function 'int main()':
toll.cpp:45:33: error: 's' was not declared in this scope
   E.emplace_back(u, v, C[i], 0);s
                                 ^
toll.cpp:37:18: warning: unused variable 'c' [-Wunused-variable]
  int i, j, u, v, c;
                  ^
toll.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &n, &m, &k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
toll.cpp:44:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &u, &v, C + i);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
toll.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &u, &v);
  ~~~~~^~~~~~~~~~~~~~~~
toll.cpp:52:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", X + i);
   ~~~~~^~~~~~~~~~~~~