using ll=longlong; using ull=unsignedlonglong; using pii=pair<int,int>; #define begend(x) x.begin(),x.end() #define mem0(x) memset(x,0,sizeof(x)) #define YES puts("Yes") #define NO puts("No")
intread(){ int f=1,x=0;char c=getchar(); while(!isdigit(c)){if(c=='-')f=-1;c=getchar();} while(isdigit(c)){x=x*10+c-'0';c=getchar();} return x*f; }
voidsolve(int kase){ int a=read(),b=read(); printf("%d\n",a+b); }
intmain(){ int T=read(),TT=1; while(T--){ solve(TT++); } return0; }
using ll=longlong; using ull=unsignedlonglong; using pii=pair<int,int>; #define begend(x) x.begin(),x.end() #define mem0(x) memset(x,0,sizeof(x)) #define YES puts("Yes") #define NO puts("No")
intread(){ int f=1,x=0;char c=getchar(); while(!isdigit(c)){if(c=='-')f=-1;c=getchar();} while(isdigit(c)){x=x*10+c-'0';c=getchar();} return x*f; }
constint N = 2e5+5;
int ans[N]; voidsolve(int kase){ int n=read(); if(n==1)puts("1"); elseif(n==2)puts("1 2"); elseif(n==3)puts("3 1 2"); else{ ans[1]=2;ans[n]=3; int pos1 = (1+n)/2; ans[pos1]=1; int now = 4; for(int i=pos1+1;i<n;i++){ ans[i]=now++; } for(int i=2;i<pos1;i++){ ans[i]=now++; } for(int i=1;i<=n;i++){ printf("%d ",ans[i]); } puts(""); } }
intmain(){ int T=read(),TT=1; while(T--){ solve(TT++); } return0; }
C. Particles
题意
有 n 个整数,−109≤ci≤109,每次操作可以选择一个数删去,然后将它两边的数(如果有)加起来,合并为一个新的数。求出最后剩下的数的最大值。
using ll=longlong; using ull=unsignedlonglong; using pii=pair<int,int>; #define begend(x) x.begin(),x.end() #define mem0(x) memset(x,0,sizeof(x)) #define YES puts("Yes") #define NO puts("No")
intread(){ int f=1,x=0;char c=getchar(); while(!isdigit(c)){if(c=='-')f=-1;c=getchar();} while(isdigit(c)){x=x*10+c-'0';c=getchar();} return x*f; }
constint N = 2e5+5; ll a[N]; voidsolve(int kase){ int n=read(); bool flag = 0; for(int i=0;i<n;i++){ a[i]=read(); if(a[i]>0)flag=1; }
using ll=longlong; using ull=unsignedlonglong; using pii=pair<int,int>; #define begend(x) x.begin(),x.end() #define mem0(x) memset(x,0,sizeof(x)) #define YES puts("Yes") #define NO puts("No")
intread(){ int f=1,x=0;char c=getchar(); while(!isdigit(c)){if(c=='-')f=-1;c=getchar();} while(isdigit(c)){x=x*10+c-'0';c=getchar();} return x*f; } constint N = 1e6+5;
using ll=longlong; using ull=unsignedlonglong; using pii=pair<int,int>; #define begend(x) x.begin(),x.end() #define mem0(x) memset(x,0,sizeof(x)) #define YES puts("Yes") #define NO puts("No")
intread(){ int f=1,x=0;char c=getchar(); while(!isdigit(c)){if(c=='-')f=-1;c=getchar();} while(isdigit(c)){x=x*10+c-'0';c=getchar();} return x*f; }
constint N = 4e3+5; structEdge{ int v,w; }; vector<Edge> G[N];
voidsolve(int kase){ int n=read(),m=read(),k=read();
for(int i=1;i<=n+m;i++)G[i].clear();
for(int i=0;i<k;i++){ int x1=read(),y1=read(),x2=read(),y2=read(); int x=x1,y=min(y1,y2)+n; int val=(y2==y1+1); G[x].push_back({y,val}); G[y].push_back({x,val}); }