제출 #1330729

#제출 시각아이디문제언어결과실행 시간메모리
1330729kadirArranging Shoes (IOI19_shoes)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
const ll mod=1e9+7;
const ll inf=1e18;
const ll mxn=2e5+5;
ll t[4*mxn];
bool bo[mxn];
void build(ll node,ll l,ll r,ll L,ll val) {
	if(L>r||L<l) return;
	if(l==r) {
		t[node]=val;
		return;
	}
	ll mid=(l+r)/2;
	build(node*2,l,mid,L,val);
	build(node*2+1,mid+1,r,L,val);
	t[node]=t[node*2]+t[node*2+1];
}
ll query(ll node,ll l,ll r,ll L,ll R) {
	if(R<l||L>r) return 0;
	if(l>L&&r<R) {
		return t[node];
	}
	ll mid=(l+r)/2;
	ll x=query(node*2,l,mid,L,R);
	ll y=query(node*2+1,mid+1,r,L,R);
	return x+y;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vector<ll> s(n);
	for(int i=0; i<n; i++) {
		cin>>s[i];
	}
	ll ans=0;
	vector<pair<ll,ll>> v;
	for(int i=0; i<n; i++) {
		build(1,1,n,i+1,1);
		v.pb({s[i],i+1});
	}
	sort(v.begin(),v.end());
	for(int i=0; i<n; i++) {
		if(bo[i]) {
			continue;
		}
		ll x=s[i]*-1;
		pair<ll,ll> p= {x,i+1};
		ll o=upper_bound(v.begin(),v.end(),p)-v.begin();
		ll k=query(1,1,n,(i+1)*2,o);
		build(1,1,n,o+1,0);
		bo[o]=1;
		v[o].ss=0;
		sort(v.begin(),v.end());
		if(x<0) {
			k++;
		}
		ans+=k;
	}
	cout<<ans;
}

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

/usr/bin/ld: /tmp/cc7O4hdQ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc0jysX8.o:shoes.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc7O4hdQ.o: in function `main':
grader.cpp:(.text.startup+0x26b): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status