답안 #150646

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
150646 2019-09-01T08:46:22 Z 还没编好(#3801, cauchysheep, fjzzq2002, apiad) 포도주 시음 (FXCUP4_wine) C++17
5 / 100
12 ms 1092 KB
#include "bartender.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
std::vector<int> BlendWines(int K, std::vector<int> a){
	int N = a.size();
	int G=min(N,11);
	vector<int> s;
	for(int i=0;i<N;++i)
		if(a[i]>G)
			s.pb(a[i]-G);
	__int128 p=0;
	//encode this shit
	for(int j=0;j<s.size();++j)
	{
		int w=0;
		for(int k=0;k<j;++k)
			w+=s[k]<s[j];
		p=p*(j+1)+w;
	}
	vector<int> o(N);
	for(int i=0;i<N;++i)
	{
		int u=2;
		if(a[i]>G) u=6;
		int x=p%u; p/=u;
		if(a[i]>G)
			o[i]=x+3;
		else o[i]=x+1;
	}
	assert(p==0);
	return o;
}
#include "taster.h"
#include <bits/stdc++.h>
using namespace std;


typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int pos[100999],N,bs[109999];
void edt(int x,int y)
{
	for(;x<=N;x+=x&-x) bs[x]+=y;
}
int qry(int x)
{
	int s=0;
	for(;x>=1;x-=x&-x) s+=bs[x];
	return s;
}
int query(int p,int q)
{
	return Compare(p,q)==-1;
}
vector<int> sortr(vector<int> v)
{
	if(v.size()<=1) return v;
	int n=v.size();
	vector<int> t;
	for(int i=0;i+1<n;i+=2)
	{
		//v[i]<v[i+1]
		if(!query(v[i],v[i+1])) swap(v[i],v[i+1]);
		t.pb(v[i+1]);
	}
	t=sortr(t);
	for(auto r:v) pos[r]=-1;
	for(int i=0;i<int(t.size());++i)
		pos[t[i]]=i;
	N=t.size();
	for(int i=1;i<=N;++i) bs[i]=0;
	for(int i=2;i<=N;++i) edt(i,1);
	for(int i=0;i<N;++i)
		assert(qry(i+1)==i);
	pos[0]=1e9;
	vector<pii> vp;
	for(int i=0;i<n;i+=2)
	{
		if(i+1<n)
			vp.pb(mp(v[i],v[i+1]));
		else vp.pb(mp(v[i],0));
	}
	sort(vp.begin(),vp.end(),[&]
	(pii a,pii b) {return pos[a.se]<pos[b.se];});
	int vn=vp.size();
	for(int l=0,c=0,b=0,r,s;l<vn;l=r+1,b=s,++c)
	{
		if(c==0) s=1;
		else if(c==1) s=2;
		else s=(1<<c)-b;
		r=min(l+s-1,vn-1);
		for(int j=r;j>=l;--j)
		{
			pii w=vp[j]; int p;
			if(!w.se) p=t.size();
			else p=qry(pos[w.se]+1);
			int ip;
			{
			int l=0,r=p;
			while(l<r)
			{
				int m=(l+r)>>1;
				if(query(t[m],w.fi)) l=m+1; else r=m;
			}
			ip=l;
			}
			t.insert(t.begin()+ip,w.fi);
			{
			int l=1,r=N+1;
			while(l<r)
			{
				int m=(l+r)>>1;
				if(qry(m)>=ip) r=m; else l=m+1;
			}
			edt(l,1);
			}
		}
	}
	return t;
}

//optimal sort end


#define pb push_back
#define SZ 666666
bool big[SZ];
int g[SZ],c[SZ];
std::vector<int> SortWines(int K, std::vector<int> o) {
	srand(123111111+__TIME__[7]*10000+__TIME__[6]*100
	+__TIME__[5]*11231+__TIME__[4]*1231+__TIME__[3]*123132
	+__TIME__[2]*12111+__TIME__[1]*11111+time(0));
	int N = o.size();
	vector<int> a(N);
	int G=min(N,11);
	__int128 p=0;
	for(int i=N-1;i>=0;--i)
	{
		int u,x;
		if(o[i]>=3)
			big[i]=1,u=6,x=o[i]-3;
		else u=2,x=o[i]-1;
		p=p*u+x;
	}
	#ifdef LOCAL
	cerr<<(long long)p<<"\n";
	#endif
	for(int i=N-G-1;i>=0;--i)
	{
		g[i]=p%(i+1); p/=i+1;
	}
	for(int i=0;i<=N-G-1;++i)
	{
		c[i]=g[i];
		for(int j=0;j<i;++j)
			if(c[j]>=g[i]) ++c[j];
	}
	int oo=0;
	for(int i=0;i<N;++i)
		if(big[i]) a[i]=c[oo++]+G+1;
	vector<int> S;
	for(int i=0;i<N;++i)
		if(!big[i]) S.pb(i);
	random_shuffle(S.begin(),S.end());
	S=sortr(S);
	for(int i=0;i<S.size();++i)
		a[S[i]]=i+1;
	#ifdef LOCAL
	for(auto t:o)
		cout<<t<<",";
	cout<<"\n";
	for(auto t:a)
		cout<<t<<",";
	cout<<"\n";
	#endif
	return a;
}

Compilation message

bartender.cpp: In function 'std::vector<int> BlendWines(int, std::vector<int>)':
bartender.cpp:14:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int j=0;j<s.size();++j)
              ~^~~~~~~~~

taster.cpp: In function 'std::vector<int> SortWines(int, std::vector<int>)':
taster.cpp:137:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<S.size();++i)
              ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 772 KB Correct
2 Correct 10 ms 772 KB Correct
3 Correct 9 ms 924 KB Correct
4 Correct 10 ms 788 KB Correct
5 Correct 8 ms 644 KB Correct
6 Correct 9 ms 780 KB Correct
7 Correct 8 ms 644 KB Correct
8 Correct 8 ms 644 KB Correct
9 Correct 10 ms 908 KB Correct
10 Correct 9 ms 644 KB Correct
11 Correct 9 ms 932 KB Correct
12 Correct 9 ms 772 KB Correct
13 Correct 10 ms 824 KB Correct
14 Correct 10 ms 780 KB Correct
15 Correct 9 ms 772 KB Correct
16 Correct 10 ms 1004 KB Correct
17 Correct 10 ms 1016 KB Correct
18 Correct 8 ms 772 KB Correct
19 Correct 9 ms 644 KB Correct
20 Correct 9 ms 644 KB Correct
21 Correct 10 ms 772 KB Correct
22 Correct 9 ms 772 KB Correct
23 Correct 10 ms 772 KB Correct
24 Partially correct 9 ms 772 KB Wrong
25 Correct 10 ms 772 KB Correct
26 Correct 10 ms 772 KB Correct
27 Correct 9 ms 772 KB Correct
28 Correct 10 ms 908 KB Correct
29 Correct 10 ms 908 KB Correct
30 Correct 10 ms 880 KB Correct
31 Correct 12 ms 644 KB Correct
32 Correct 10 ms 772 KB Correct
33 Correct 10 ms 888 KB Correct
34 Correct 10 ms 908 KB Correct
35 Correct 9 ms 908 KB Correct
36 Correct 9 ms 908 KB Correct
37 Correct 9 ms 908 KB Correct
38 Correct 9 ms 644 KB Correct
39 Correct 10 ms 772 KB Correct
40 Correct 9 ms 772 KB Correct
41 Correct 10 ms 908 KB Correct
42 Correct 10 ms 788 KB Correct
43 Correct 9 ms 908 KB Correct
44 Correct 9 ms 772 KB Correct
45 Correct 9 ms 772 KB Correct
46 Correct 10 ms 1032 KB Correct
47 Correct 8 ms 644 KB Correct
48 Correct 9 ms 1012 KB Correct
49 Correct 10 ms 888 KB Correct
50 Correct 9 ms 772 KB Correct
51 Correct 9 ms 908 KB Correct
52 Correct 9 ms 908 KB Correct
53 Correct 10 ms 772 KB Correct
54 Correct 8 ms 772 KB Correct
55 Correct 10 ms 908 KB Correct
56 Correct 10 ms 868 KB Correct
57 Correct 9 ms 772 KB Correct
58 Correct 10 ms 772 KB Correct
59 Correct 9 ms 908 KB Correct
60 Correct 8 ms 772 KB Correct
61 Correct 10 ms 772 KB Correct
62 Correct 10 ms 772 KB Correct
63 Correct 9 ms 696 KB Correct
64 Correct 9 ms 772 KB Correct
65 Correct 9 ms 772 KB Correct
66 Correct 10 ms 772 KB Correct
67 Correct 8 ms 772 KB Correct
68 Correct 9 ms 908 KB Correct
69 Correct 8 ms 908 KB Correct
70 Correct 9 ms 1092 KB Correct
71 Correct 10 ms 908 KB Correct
72 Correct 8 ms 772 KB Correct
73 Correct 9 ms 908 KB Correct
74 Correct 9 ms 884 KB Correct
75 Correct 10 ms 772 KB Correct
76 Correct 8 ms 908 KB Correct
77 Correct 9 ms 772 KB Correct
78 Correct 10 ms 772 KB Correct
79 Correct 9 ms 772 KB Correct
80 Correct 10 ms 908 KB Correct
81 Correct 10 ms 644 KB Correct
82 Correct 8 ms 644 KB Correct
83 Correct 9 ms 908 KB Correct
84 Correct 10 ms 772 KB Correct
85 Correct 9 ms 772 KB Correct
86 Correct 9 ms 908 KB Correct
87 Correct 9 ms 908 KB Correct
88 Correct 8 ms 772 KB Correct
89 Correct 9 ms 1020 KB Correct
90 Correct 8 ms 1016 KB Correct
91 Correct 10 ms 1008 KB Correct
92 Correct 9 ms 908 KB Correct
93 Correct 9 ms 932 KB Correct
94 Correct 8 ms 884 KB Correct
95 Correct 10 ms 772 KB Correct
96 Correct 9 ms 772 KB Correct
97 Correct 9 ms 1012 KB Correct
98 Correct 10 ms 844 KB Correct
99 Correct 10 ms 772 KB Correct
100 Correct 10 ms 884 KB Correct
101 Correct 8 ms 644 KB Correct
102 Correct 9 ms 868 KB Correct
103 Correct 8 ms 776 KB Correct
104 Correct 10 ms 908 KB Correct
105 Correct 9 ms 784 KB Correct
106 Correct 10 ms 908 KB Correct
107 Partially correct 8 ms 784 KB Wrong
108 Partially correct 10 ms 644 KB Wrong
109 Partially correct 8 ms 792 KB Wrong
110 Partially correct 9 ms 1024 KB Wrong
111 Partially correct 10 ms 772 KB Wrong
112 Partially correct 9 ms 908 KB Wrong
113 Partially correct 8 ms 644 KB Wrong
114 Partially correct 9 ms 892 KB Wrong
115 Correct 10 ms 772 KB Correct
116 Partially correct 8 ms 772 KB Wrong
117 Partially correct 9 ms 884 KB Wrong
118 Partially correct 8 ms 772 KB Wrong
119 Partially correct 8 ms 644 KB Wrong
120 Partially correct 9 ms 784 KB Wrong