답안 #25371

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
25371 2017-06-21T16:43:22 Z gabrielsimoes Palembang Bridges (APIO15_bridge) C++14
0 / 100
0 ms 2024 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;

int main()
{
	int m, n;
	scanf("%d %d", &m, &n);

	char a,c;
	ll b,d, ans0 = 0;
	vector<pll> v;
	for (int i = 0; i < n; i++) {
		scanf(" %c %lld %c %lld",&a, &b,&c, &d);
		if (d < b) swap(b,d);
		
		if (a == c) ans0 += d - b;
		else v.push_back(pll(b,d)), ans0++;
	}

	if (m == 1) {
		vector<ll> all;
		for (pll& p : v)
			all.push_back(p.first), all.push_back(p.second);
		sort(all.begin(), all.end());
		ll x = all[all.size()/2 - 1];
		for (ll y : all)
			ans0 += abs(y - x);
		printf("%lld\n", ans0);
		return 0;
	}
}

Compilation message

bridge.cpp: In function 'int main()':
bridge.cpp:10:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &m, &n);
                        ^
bridge.cpp:16:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c %lld %c %lld",&a, &b,&c, &d);
                                          ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 2024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 2024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2024 KB Output isn't correct
2 Halted 0 ms 0 KB -