跳到正文

Daitsat

1069863

泪水将我淹没

在洛谷打开
资料、奖项与版本

资料

编号
1069863
抓取

奖项

2023 CSP-J
二等奖

2024.4.29 AFO 的基本信息

https://lyrics.lyricfind.com/

131081200809232581 Page Views Count

摩斯



缓缓飘落的枫叶像思念,缓缓飘落的枫叶像思念,

为何挽回要赶在冬天来之前,为何挽回要赶在冬天来之前,

爱你穿越时间,爱你穿越时间,

两行来自秋末的眼泪,两行来自秋末的眼泪,

让爱渗透了地面,让爱渗透了地面,

我要的只是你在我身边。我要的只是你在我身边。

——《枫》——《枫》



『我不知我们何时能再相遇』\LARGE\textcolor{#87CEFA}{『我不知我们何时能再相遇』}

—II don′tdon't knowknow whenwhen we′llwe'll meetmeet againagain—

『如果相遇』\Large\textcolor{#66CDAA}{『如果相遇』}

—IfIf wewe meetmeet—

『期望不是你与我站在了彼端与异端』\large\textcolor{#7FFFD4}{『期望不是你与我站在了彼端与异端』}

—II hopehope it′sit's notnot thatthat—

—youyou andand II areare onon thethe otherother sideside andand thethe otherother sideside—

我在干嘛?我在看手机我在干嘛?我在看手机

在各种app间穿梭在各种app间穿梭

不停的接收各种碎片信息来消磨不停的接收各种碎片信息来消磨

等待你回消息这一段空白时间等待你回消息这一段空白时间

我在干嘛我在想你我在干嘛 我在想你

狗狗 小宝,我想你了

颜色表

大事忌

23.9.25 AC 150

好玩的 桌游 1 暴力 图床1 图床2 同学 神贴 搜东西的 GPT 音乐 随机 55 小说 闫强大大

int

C++
int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
void write(int x){
	 if(x==0){
	 	putchar('0');return;
	 }
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}

long long

C++
long long read1(){
    long long x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
void write1(long long x){
	 if(x==0){
	 	putchar('0');return;
	 }
     if(x<0) putchar('-'),x=-x;
     if(x>9) write1(x/10);
     putchar(x%10+'0');
}

string

C++
inline string read(){
	char ch=getchar();
	string st1="";
	while(!((ch>='a')&&(ch<='z')))
	  ch=getchar();
	while((ch>='a')&&(ch<='z')) 
	  st1+=ch,ch=getchar();
	return st1;
}
inline void write(string s){
	for(int i=0;i<s.size();i++) putchar(s[i]);
}

double

C++
inline double read(){
    long long s=0,w=1,k=0,n=0,m=0;
    char ch=getchar(); 
    while(ch<'0'||ch>'9'){
        if(ch=='-') w=-1;
        ch=getchar();
    }
    while((ch>='0'&&ch<='9')||ch=='.'){
        if(ch=='.') n=1;
        else if(n==0) s=s*10+ch-'0';
             else k=k*10+ch-'0',m++;
        ch=getchar();
    }
    return (pow(0.1,m)*k+s)*w;
}

可以传多参数的

C++
    template <typename T> inline void read(T& x){x = 0; bool f = false; char ch = getchar(); while(ch < '0' || ch > '9'){if(ch == '-') f = !f; ch = getchar();}while(ch >= '0' && ch <= '9'){x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();} x = (f ? -x : x); return;}
    template <typename T, typename... Args> inline void read(T& x, Args&...x_){read(x), read(x_...);}
    template <typename T> inline void put(T x){if(x < 0) putchar('-'), x = -x; if(x > 9) put(x / 10); putchar(x % 10 + '0'); return ;}
    template <typename T> inline void write(T x){put(x);}
    template <typename T, typename... Args> inline void write(T x, Args...x_){write(x), write(x_...);}

teacher’s 线段树

C++
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mid (h+t)/2
const int N=1e6+10;
int a[N],n,m;
struct sgt{
    int v[N*4],lazy[N*4];
    void down(int x,int h,int t){
        v[x*2]+=lazy[x]*(mid-h+1); v[x*2+1]+=lazy[x]*(t-mid);
        lazy[x*2]+=lazy[x]; lazy[x*2+1]+=lazy[x];
        lazy[x]=0;
    }
    void g(int x,int h,int t,int h1,int t1,int vv){
        if (h1<=h&&t<=t1){
            v[x]+=(t-h+1)*vv;
            lazy[x]+=vv;
            return;
        }
        down(x,h,t);
        if (h1<=mid) g(x*2,h,mid,h1,t1,vv);
        if (mid<t1) g(x*2+1,mid+1,t,h1,t1,vv);
        v[x]=v[x*2]+v[x*2+1];
    }
    int q(int x,int h,int t,int h1,int t1){
        if (h1<=h&&t<=t1){
            return v[x];
        }
        down(x,h,t);
        int ans=0;
        if (h1<=mid) ans+=q(x*2,h,mid,h1,t1);
        if (mid<t1) ans+=q(x*2+1,mid+1,t,h1,t1);
        return ans;
    }
}S;
signed main(){
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for (int i=1;i<=n;i++) {
        cin>>a[i];
        S.g(1,1,n,i,i,a[i]);
    }
    for (int i=1;i<=m;i++) {
        int k,x,y,z;
        cin>>k;
        if (k==1){
            cin>>x>>y>>z;
            S.g(1,1,n,x,y,z);
        } else {
            cin>>x>>y;
            cout<<S.q(1,1,n,x,y)<<endl;
        }
    }
    return 0;
}

二分答案

#define mid (h+t)/2;

C++
bool check(int x)
{
	for(int i=1;i<=n;i++) if(a[i]>x) return 0;
	int sum=0,cnt=1;
	for(int i=1;i<=n;i++)
	{
		if(sum+a[i]>x) sum=a[i],cnt++;
		else sum+=a[i];
	}
	return cnt<=m;
}
//二分
	int h=0,t=1e9;
	while(h+10<t)
	{
		if(check(mid)) t=mid;
		else h=mid;
	}
	for(int i=h;i<=t;i++)
	{
		if(check(i))
		{
			cout<<i<<endl;
			return 0;
		}
	}

Trie字典树

C++
int in(char s[]){//建树
	int p=0;
	for(int i=0;s[i];i++){
		int a=s[i]-'a';
		if(!ch[p][a]) ch[p][a]=++idx;
		p=ch[p][a];
	}
	cnt[p]++;//串尾
}
int sf(char *s){//查询
	int p=0;
	for(int i=0;s[i];i++){
		int a=s[i]-'a';
		if(!ch[p][a]) return 0;
		p=ch[p][a];
	}
	return cnt[p];
}
共 1 篇
  1. 题解

    SP7 BULK - The Bulk!

    题目传送门:BULK - The Bulk! 解释: 首先,找到已知为外部面的一个面,然后选择该面上的任意一条边。将面和属于它的边的组合称为“面边”。然后,从初始面边开始进行搜索(BFS或DFS或其他方式),为我们遇到的所有面边分配一个方向。这样我们就可以将所有外部面定向。然后,…

    3 赞