답안 #1013579

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013579 2024-07-03T16:41:13 Z vjudge1 시간이 돈 (balkan11_timeismoney) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll;
#define MEMSET_MAX 0x7f
#define testcases \
  int test_amount;        \
  cin >> test_amount;       \
  while (test_amount--)
const ll inf = 1e16; const int mod = 1e9+7;

ll n, m, sum, x, y, t, c, tsum, csum;
bool visited[203], pet;
vector<pair<ll, pll>> adj[203];
set<pair<ll, pll>> e; 
pair<ll, pll> w;
vector<pll> res;
map<pll, bool> mp;

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  
  cin >> n >> m;
  
  pet = 1;
  for (int i = 1; i <= m; i++) {
  	cin >> x >> y >> t >> c;
  	adj[x].push_back({t, {x, y}});
  	adj[y].push_back({t, {x, y}});
  	
  	if (t != c) pet = 0;
  	res.push_back({x, y});
  	
  	tsum += t; csum += c;
  }
  
  if (pet && m == n-1) {
  	cout << tsum << " " << csum << "\n";
  	for (auto i : res) cout << i.first << " " << i.second << "\n"
  	return 0;
  } res.clear();
  
  visited[0] = 1;
  for (auto i : adj[0]) {e.insert(i); mp[{i.second.first, i.second.second}] = 1;}
  
  while (!e.empty()) {	
	w = (*e.begin());
  	
  	if (visited[(*e.begin()).second.first] == 0 || visited[(*e.begin()).second.second] == 0) {
  		sum += (*e.begin()).first;
  		
  		x = (*e.begin()).second.first; y = (*e.begin()).second.second;
  		//cout << "edge " << x << " " << y << "\n";
  		
  		if (!visited[x]) for (auto i : adj[x]) {
  			//cout << i.second.first << " " << i.second.second << " " << mp[{i.second.first, i.second.second}] << "\n";
  			 	
  			if (mp[{i.second.first, i.second.second}]) continue;
  			e.insert(i); mp[{i.second.first, i.second.second}] = 1;
		}
		
  		if (!visited[y]) for (auto i : adj[y]) {
  			//cout << i.second.first << " " << i.second.second << " " << mp[{i.second.first, i.second.second}] << "\n";
  			
  			if (mp[{i.second.first, i.second.second}]) continue;
  			e.insert(i); mp[{i.second.first, i.second.second}] = 1;
		}
  		
		visited[x] = 1; visited[y] = 1;
		res.push_back({x, y});
	}
  	e.erase(w);
  }
  
  for (auto i : e) {
  	if (visited[i.second.first] == 0 || visited[i.second.second] == 0) {
	  	sum += i.first;
	  	visited[i.second.first] = 1; visited[i.second.second] = 1;
	  	res.push_back({i.second.first, i.second.second});
	}
  }
  
  cout << sum << " " << sum << "\n";
  for (auto i : res) cout << i.first << " " << i.second << "\n";   

  return 0;
}

Compilation message

timeismoney.cpp: In function 'int main()':
timeismoney.cpp:41:65: error: expected ';' before 'return'
   41 |    for (auto i : res) cout << i.first << " " << i.second << "\n"
      |                                                                 ^
      |                                                                 ;
   42 |    return 0;
      |    ~~~~~~