Submission #153370

# Submission time Handle Problem Language Result Execution time Memory
153370 2019-09-13T18:38:56 Z Utaha Arranging Shoes (IOI19_shoes) C++14
50 / 100
1000 ms 11252 KB
/*input

*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
#define version 20190814
//}}}
const ll maxn=100005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

int n;
vector<pii> p;

vector<int> sz[maxn+maxn];
int pt[maxn+maxn];

int BIT[maxn+maxn];
int low(int i){
	return i&-i;
}

void mdf(int n,int d){
	for(int i=n;i<maxn+maxn;i+=low(i+1)){
		BIT[i]+=d;
	}
}
int query(int n){
	int ret=0;
	for(int i=n;i>=0;i-=low(i+1)){
		ret+=BIT[i];
	}
	return ret;
}
int query(int l,int r){
	return query(r-1)-query(l-1);
}

ll count_swaps(vector<int> a){
	ll ans=0;
	n=SZ(a)/2;
	REP(i,n+n){
		int cur=a[i];
		if(pt[-cur+maxn]==SZ(sz[-cur+maxn])){
			sz[cur+maxn].pb(i);
		}
		else{
			p.eb(sz[maxn-cur][pt[maxn-cur]],i);
			if(cur<0) ans++;
			pt[maxn-cur]++;
		}
	}
	sort(ALL(p));
	for(int i=0;i<SZ(p);i++) for(int j=i+1;j<SZ(p);j++){
		if(p[i].S<p[j].F);
		else if(p[i].S<p[j].S) ans++;
		else ans+=2;
	}
	// for(auto i:p){
	// 	ans+=2*(query(i.S,n+2))+query(i.F,i.S);
	// 	mdf(i.S,1);
	// }
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 6 ms 4984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 6 ms 4984 KB Output is correct
3 Correct 6 ms 4984 KB Output is correct
4 Correct 6 ms 4984 KB Output is correct
5 Correct 6 ms 4988 KB Output is correct
6 Correct 6 ms 4984 KB Output is correct
7 Correct 6 ms 4984 KB Output is correct
8 Correct 6 ms 4984 KB Output is correct
9 Correct 7 ms 4984 KB Output is correct
10 Correct 7 ms 4984 KB Output is correct
11 Correct 6 ms 4984 KB Output is correct
12 Correct 6 ms 4988 KB Output is correct
13 Correct 6 ms 4984 KB Output is correct
14 Correct 6 ms 4988 KB Output is correct
15 Correct 6 ms 4984 KB Output is correct
16 Correct 6 ms 4984 KB Output is correct
17 Correct 6 ms 4956 KB Output is correct
18 Correct 6 ms 4984 KB Output is correct
19 Correct 6 ms 4984 KB Output is correct
20 Correct 7 ms 5092 KB Output is correct
21 Correct 6 ms 4984 KB Output is correct
22 Correct 6 ms 4984 KB Output is correct
23 Correct 6 ms 4956 KB Output is correct
24 Correct 6 ms 4984 KB Output is correct
25 Correct 6 ms 4984 KB Output is correct
26 Correct 7 ms 5100 KB Output is correct
27 Correct 6 ms 4984 KB Output is correct
28 Correct 7 ms 4984 KB Output is correct
29 Correct 6 ms 4984 KB Output is correct
30 Correct 8 ms 4984 KB Output is correct
31 Correct 8 ms 4984 KB Output is correct
32 Correct 8 ms 4984 KB Output is correct
33 Correct 7 ms 4984 KB Output is correct
34 Correct 7 ms 4984 KB Output is correct
35 Correct 6 ms 4984 KB Output is correct
36 Correct 8 ms 5056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 6 ms 4984 KB Output is correct
3 Correct 6 ms 4988 KB Output is correct
4 Correct 6 ms 4984 KB Output is correct
5 Correct 6 ms 4984 KB Output is correct
6 Correct 6 ms 4984 KB Output is correct
7 Correct 6 ms 4984 KB Output is correct
8 Correct 6 ms 4984 KB Output is correct
9 Correct 6 ms 4984 KB Output is correct
10 Correct 6 ms 4984 KB Output is correct
11 Correct 6 ms 4984 KB Output is correct
12 Correct 6 ms 4984 KB Output is correct
13 Correct 6 ms 4984 KB Output is correct
14 Correct 6 ms 4984 KB Output is correct
15 Correct 6 ms 4984 KB Output is correct
16 Correct 6 ms 4984 KB Output is correct
17 Correct 6 ms 4984 KB Output is correct
18 Correct 7 ms 4984 KB Output is correct
19 Correct 7 ms 4984 KB Output is correct
20 Correct 35 ms 5496 KB Output is correct
21 Correct 35 ms 5496 KB Output is correct
22 Execution timed out 1073 ms 9456 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 7 ms 4984 KB Output is correct
3 Correct 7 ms 5112 KB Output is correct
4 Correct 6 ms 4984 KB Output is correct
5 Execution timed out 1086 ms 11252 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 6 ms 4984 KB Output is correct
3 Correct 6 ms 4984 KB Output is correct
4 Correct 6 ms 4984 KB Output is correct
5 Correct 6 ms 4988 KB Output is correct
6 Correct 6 ms 4984 KB Output is correct
7 Correct 6 ms 4984 KB Output is correct
8 Correct 6 ms 4984 KB Output is correct
9 Correct 7 ms 4984 KB Output is correct
10 Correct 7 ms 4984 KB Output is correct
11 Correct 6 ms 4984 KB Output is correct
12 Correct 6 ms 4988 KB Output is correct
13 Correct 6 ms 4984 KB Output is correct
14 Correct 6 ms 4988 KB Output is correct
15 Correct 6 ms 4984 KB Output is correct
16 Correct 6 ms 4984 KB Output is correct
17 Correct 6 ms 4956 KB Output is correct
18 Correct 6 ms 4984 KB Output is correct
19 Correct 6 ms 4984 KB Output is correct
20 Correct 7 ms 5092 KB Output is correct
21 Correct 6 ms 4984 KB Output is correct
22 Correct 6 ms 4984 KB Output is correct
23 Correct 6 ms 4956 KB Output is correct
24 Correct 6 ms 4984 KB Output is correct
25 Correct 6 ms 4984 KB Output is correct
26 Correct 7 ms 5100 KB Output is correct
27 Correct 6 ms 4984 KB Output is correct
28 Correct 7 ms 4984 KB Output is correct
29 Correct 6 ms 4984 KB Output is correct
30 Correct 8 ms 4984 KB Output is correct
31 Correct 8 ms 4984 KB Output is correct
32 Correct 8 ms 4984 KB Output is correct
33 Correct 7 ms 4984 KB Output is correct
34 Correct 7 ms 4984 KB Output is correct
35 Correct 6 ms 4984 KB Output is correct
36 Correct 8 ms 5056 KB Output is correct
37 Correct 6 ms 4984 KB Output is correct
38 Correct 6 ms 4984 KB Output is correct
39 Correct 6 ms 4984 KB Output is correct
40 Correct 7 ms 4988 KB Output is correct
41 Correct 7 ms 5112 KB Output is correct
42 Correct 7 ms 5112 KB Output is correct
43 Correct 7 ms 5112 KB Output is correct
44 Correct 7 ms 5112 KB Output is correct
45 Correct 7 ms 5112 KB Output is correct
46 Correct 7 ms 5112 KB Output is correct
47 Correct 7 ms 5116 KB Output is correct
48 Correct 7 ms 5112 KB Output is correct
49 Correct 7 ms 5112 KB Output is correct
50 Correct 7 ms 4984 KB Output is correct
51 Correct 7 ms 4984 KB Output is correct
52 Correct 7 ms 5112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 6 ms 4984 KB Output is correct
3 Correct 6 ms 4984 KB Output is correct
4 Correct 6 ms 4984 KB Output is correct
5 Correct 6 ms 4988 KB Output is correct
6 Correct 6 ms 4984 KB Output is correct
7 Correct 6 ms 4984 KB Output is correct
8 Correct 6 ms 4984 KB Output is correct
9 Correct 7 ms 4984 KB Output is correct
10 Correct 7 ms 4984 KB Output is correct
11 Correct 6 ms 4984 KB Output is correct
12 Correct 6 ms 4988 KB Output is correct
13 Correct 6 ms 4984 KB Output is correct
14 Correct 6 ms 4988 KB Output is correct
15 Correct 6 ms 4984 KB Output is correct
16 Correct 6 ms 4984 KB Output is correct
17 Correct 6 ms 4956 KB Output is correct
18 Correct 6 ms 4984 KB Output is correct
19 Correct 6 ms 4984 KB Output is correct
20 Correct 7 ms 5092 KB Output is correct
21 Correct 6 ms 4984 KB Output is correct
22 Correct 6 ms 4984 KB Output is correct
23 Correct 6 ms 4956 KB Output is correct
24 Correct 6 ms 4984 KB Output is correct
25 Correct 6 ms 4984 KB Output is correct
26 Correct 7 ms 5100 KB Output is correct
27 Correct 6 ms 4984 KB Output is correct
28 Correct 7 ms 4984 KB Output is correct
29 Correct 6 ms 4984 KB Output is correct
30 Correct 8 ms 4984 KB Output is correct
31 Correct 8 ms 4984 KB Output is correct
32 Correct 8 ms 4984 KB Output is correct
33 Correct 7 ms 4984 KB Output is correct
34 Correct 7 ms 4984 KB Output is correct
35 Correct 6 ms 4984 KB Output is correct
36 Correct 8 ms 5056 KB Output is correct
37 Correct 6 ms 4988 KB Output is correct
38 Correct 6 ms 4984 KB Output is correct
39 Correct 6 ms 4984 KB Output is correct
40 Correct 6 ms 4984 KB Output is correct
41 Correct 6 ms 4984 KB Output is correct
42 Correct 6 ms 4984 KB Output is correct
43 Correct 6 ms 4984 KB Output is correct
44 Correct 6 ms 4984 KB Output is correct
45 Correct 6 ms 4984 KB Output is correct
46 Correct 6 ms 4984 KB Output is correct
47 Correct 6 ms 4984 KB Output is correct
48 Correct 6 ms 4984 KB Output is correct
49 Correct 6 ms 4984 KB Output is correct
50 Correct 6 ms 4984 KB Output is correct
51 Correct 6 ms 4984 KB Output is correct
52 Correct 7 ms 4984 KB Output is correct
53 Correct 7 ms 4984 KB Output is correct
54 Correct 35 ms 5496 KB Output is correct
55 Correct 35 ms 5496 KB Output is correct
56 Execution timed out 1073 ms 9456 KB Time limit exceeded
57 Halted 0 ms 0 KB -