제출 #1177013

#제출 시각아이디문제언어결과실행 시간메모리
1177013Kaztaev_AlisherNile (IOI24_nile)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second

using namespace std;
using ll = long long;

const ll N = 2e5+5 , inf = 2e9 + 7;
const ll INF = 1e18 ,   mod = 1e9+7;

ll w[N] , a[N] , b[N] , w1[N] , ord[N] , d[N] , n , q;
ll p[N] , sz[N];
ll cnt;
int get(int x){
	if(p[x] == x) return x;
	return p[x] = get(p[x]);
}
void merge(int a, int b){
	a = get(a);
	b = get(b);
	if(sz[b] % 2) cnt--;
	if(sz[a] % 2) cnt--;
	sz[a] += sz[b];
	p[b] = a;
	if(sz[a] % 2) cnt++;
}
vector<long long> solve(){
	vector<ll> vec(q,0);
	sort(w+1,w+1+n);
	cnt = n;
	for(int i = 1; i <= n; i++){
		p[i] = i; sz[i] = 1;
	}
	for(int i = 1; i <= q; i++) ord[i] = i;
	sort(ord+1,ord+1+q,[&](int i , int j){
		return d[i] < d[j];
	});
	sort(p+1,p+1+q);
	multiset<pair<int,int>> st;
	for(int i = 1; i+1 <= n; i++){
		st.insert({abs(w[i]-w[i+1]) , i});
	}
	for(int _ = 1; _ <= q; _++){
		int i = ord[_];
		while(st.size() && st.begin()->F <= d[i]){
			pair<ll,ll> x = *st.begin();
			st.erase(st.find(x));
			int a = x.S;
			int b = x.S+1;
			merge(a,b);
		}
		vec[i-1] = cnt+n;
	}
	return vec;
}
vector<long long> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E){
	n = W.size();
	for(int i = 1; i <= n; i++){
		w[i] = W[i-1];
		a[i] = A[i-1];
		b[i] = B[i-1];
	}
	q = E.size();
	for(int i = 1; i <= q; i++){
		d[i] = E[i-1];
	}
	return solve();
}

int main() {
  int N;
  assert(1 == scanf("%d", &N));
  std::vector<int> W(N), A(N), B(N);
  for (int i = 0; i < N; i++)
    assert(3 == scanf("%d%d%d", &W[i], &A[i], &B[i]));
  int Q;
  assert(1 == scanf("%d", &Q));
  std::vector<int> E(Q);
  for (int j = 0; j < Q; j++)
    assert(1 == scanf("%d", &E[j]));
  fclose(stdin);

  std::vector<long long> R = calculate_costs(W, A, B, E);

  int S = (int)R.size();
  for (int j = 0; j < S; j++)
    printf("%lld\n", R[j]);
  fclose(stdout);

  return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/cckCGMcc.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccgLBBJp.o:nile.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status