답안 #1027621

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1027621 2024-07-19T08:02:33 Z KasymK Fireworks (APIO16_fireworks) C++17
컴파일 오류
0 ms 0 KB
#include "bits/stdc++.h"
using namespace std;
#define ss second
#define ff first
#define ll long long
#define pb push_back
#define all(v) v.begin(), v.end()
#define pii pair<int, int>
const int N = 1e5+5;
vector<pii> adj[N];

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
	for(int i = 2; i <= n+m; ++i){
		int a, b;
		scanf("%d%d", &a, &b);
		adj[a].pb({i,b});
	}
	auto cmp = [&](pii a, pii b) -> bool {
	    return a.ss < b.ss;
	};
	sort(all(adj[x]), cmp);
	int sz = (int)adj[x].size(), x = 1;
	int ad = adj[x][sz/2].ss;
	ll answer = 0;
	for(auto i : adj[x])
	    answer += abs(ad-i.ss);
	printf("%lld", answer);
    return 0;
}

Compilation message

fireworks.cpp: In function 'int main()':
fireworks.cpp:23:15: error: 'x' was not declared in this scope
   23 |  sort(all(adj[x]), cmp);
      |               ^
fireworks.cpp:7:16: note: in definition of macro 'all'
    7 | #define all(v) v.begin(), v.end()
      |                ^
fireworks.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
fireworks.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%d%d", &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~