Jeanny
寂兮,寥兮,独立不改,周行而不殆
#include<bits/stdc++.h>

using namespace std;
int n,last,l;
int w;
priority_queue<int>dl2;
priority_queue<int,vector<int>,greater<int> >dl1;
int main(){
	freopen("live.in","r",stdin);
	freopen("live.out","w",stdout);
	cin>>n>>w;
	cin>>l;
	last=l;
	dl1.push(l);
	cout<<l<<' ';
	for(int i=2;i<=n;++i){
		scanf("%d",&l);
		if(l<last)dl2.push(l);
		else dl1.push(l);
		if((int)dl1.size()<max(1,(int)(i*w/100.0))){
			int u=dl2.top();
			dl2.pop();
			dl1.push(u);
			last=dl1.top();
		}
		if((int)dl1.size()>max(1,(int)(i*w/100.0))){
			int u=dl1.top();
			dl1.pop();
			dl2.push(u);
			last=dl1.top();
		}
		cout<<last<<' ';
	}
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
const int maxm=605;
int n,w,x,y;
struct Segmenttree{
	int l,r,sum;
}t[maxm*4];
void build(int p,int l,int r){
	t[p].l=l;
	t[p].r=r;
	if(l==r){
		return ;
	}
	int mid=l+r>>1;
	build(p*2,l,mid);
	build(p*2+1,mid+1,r);
	return ;
}
void add(int p,int val){
	if(t[p].l==t[p].r){
		t[p].sum++;
		return ;
	}
	int mid=t[p].l+t[p].r>>1;
	if(val<=mid)add(p*2,val);
	else add(p*2+1,val);
	t[p].sum=t[p*2].sum+t[p*2+1].sum;
	return ;
}
void ask(int p,int val){
	if(t[p].l==t[p].r){
		printf("%d ",t[p].l);
		return ;
	}
	if(t[p*2+1].sum>=val){
		ask(p*2+1,val);
	}
	else{
		ask(p*2,val-t[p*2+1].sum);
	}
	return ;
}
int main(){
	freopen("live.in","r",stdin);
	freopen("live.out","w",stdout);
	cin>>n>>w;
	build(1,1,600);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		add(1,x);
		int y=max(1,i*w/100);
		ask(1,y);
	}
	return 0;
}

表达式
打废物标记,不是废物标记的数字答案取反(反正法)

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
char sa[1000005],sig[1000005];
int n,b[1000005],sonl[1000005],sonr[1000005],fa[1000005],f[1000005],a[1000005];
stack<int> q;
void work(int u){
    if(b[u]) return;
    b[u] = 1;
    if(sonl[u]) work(sonl[u]);
    if(sonr[u]) work(sonr[u]);
}
int main(){
    cin.getline(sa,1000005); int len = strlen(sa);
    // printf("%s",sa);
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
    int m = n;
    for(int i = 0; i < len; i++){
        if(sa[i] == '!' || sa[i] == '&' || sa[i] == '|'){
            m++;
            if(sa[i] == '!'){
                int t = q.top(); q.pop();
                q.push(m);  sig[m] = '!'; sonl[m] = t;
                a[m] = !a[t];
            }else{
                int t1 = q.top(); q.pop();
                int t2 = q.top(); q.pop();
                q.push(m);
                sonl[m] = t1, sonr[m] = t2;
                if(sa[i] == '&'){
                    sig[m] = '&';
                    a[m] = a[t1] & a[t2];
                    if(a[t1] == 0) work(t2);
                    if(a[t2] == 0) work(t1);
                }
                else{
                    sig[m] = '|';
                    a[m] = a[t1] | a[t2];
                    if(a[t1] == 1) work(t2);
                    if(a[t2] == 1) work(t1);
                }
            }
        }else{
            if(sa[i] == 'x'){
                int sn = 0, j = i+1;
                // cout<<sa[i]<<" "<<j<<endl;
                while(sa[j] != ' '){
                    if(sa[j] >= '0' && sa[j] <= '9'){
                        sn = sn * 10 + sa[j] -'0';
                    }
                    j++;
                }
                i = j;
                q.push(sn);//
            }
        }
    }
    // for(int i = 1; i <= m; i++){
    //     cout<<i<<" "<<sig[i]<<" "<<sonl[i]<<" "<<sonr[i]<<" "<<a[i]<<endl;
    // }
    // for(int i = 1; i <= n; i++)
    //     cout<<i<<" "<<b[i]<<endl;
    int ans = a[m];
    int qq; scanf("%d",&qq);
    for(int i = 1; i <= qq; i++){
        int x; scanf("%d",&x);
        if(b[x] == 1) printf("%d\n",ans);
        else printf("%d\n",!ans);
    }
    return 0;
}

https://www.cnblogs.com/Ning-H/p/13953267.html

t4未完待续
*** 维护的关键性 ***
#include<bits/stdc++.h>
using namespace std;
int main(){
	for(int j = 1; j <= m; j++){
		f[i][j] = f[i][j-1] + a[i][j];
		for(int i = 1; i <= n; i++){
			f[i][j] = max(f[i][j-1], g[i-1][j-1] + sum[i][j-1]);
			g[i][j-1] = max(g[i-1][j-1], f[i][j-1] - sum[i-1][j]); 
		}
		for(int i = n; i >= 1; i--){
			f[i][j] = max(f[i][j-1], g[i+1][j-1] - sum[i-1][j-1]);
			g[i][j-1] = max(g[i+1][j-1], f[i][j-1] + sum[i][j]); 
		}
	}
	return 0;
}

提高组第二题 动物园
60分随便写啊

#include<bits/stdc++.h>
using namespace std;
int x,v,y,n,m,c,k,p,ans,b[105];
int lowbit(int x){
	int t = 0;
	while(x){
		x = x - (x & (-x));
		t++;
	}
	return t;
}
int main(){
	scanf("%d%d%d%d",&n,&m,&c,&k);
	for(int i = 1; i <= n; i++){
		scanf("%d",&x);
		p |= x;
	}
	for(int i = 1; i <= m; i++){
		scanf("%d%d",&v,&y);
		b[v] = 1;
	}
	for(int i = 0; i <= k-1; i++){
		if(!b[i]){
			p |= (1 << i);
		}	
	}
	int l = lowbit(p);
	printf("%d\n",(1 << l) - n);
	return 0;
}

100分好麻烦啊,那个坑爹的点就是1<<64,nnd

#include<bits/stdc++.h>
#define ull unsigned long long 
using namespace std;
long long n,m,c,k,v,y,t;
ull p,x;
int b[105];
//int x,v,y,p,ans,b[105],t;
signed main(){
	scanf("%lld%lld%lld%lld",&n,&m,&c,&k);
	for(int i = 1; i <= n; i++){
		scanf("%llu",&x);
		p |= x;
	}
	for(int i = 1; i <= m; i++){
		scanf("%lld%lld",&v,&y);
		b[v] = 1;
	}
	for(int i = 0; i <= k-1; i++ )
		if(((p>>i) & 1) || !b[i]) t++;
	if(t <= 63) printf("%llu\n",(1ull << t) - n);
	else{
		n == 0 ?puts("18446744073709551616"):printf("%llu\n",(((1ull<<63) - 1) | (1ull << 63)) - (ull)(n-1));
	}
	return 0;
}
//ull 不超过64位,所以1ull << 64是错的, (1ull<<63) - 1) | (1ull << 63)这样写是1<<64 -1的方式,不超位数
//第二ull llu真难写啊 
//输入输出是%llu,否则输出会把ll当成字符输出
posted on 2020-11-11 22:26  Jeanny  阅读(154)  评论(0)    收藏  举报