队长 · 韩天新 队员 ·GavinZheng&sshwy
C 班 RK1.
题面
B.
by sshwy
#include<bits/stdc++.h>
#define N 200005
using namespace std;
typedef long long ll;
char s[N],h[]="happiness";
int p[100000],cnt;
int times[1000],fu=false,p01,p02;
int main()
{scanf("%s",s);
int n=strlen(s);
for(int i=0;s[i];i++){if(times[s[i]]!=0){if(fu==false){p01=times[s[i]],p02=i,fu=true;
}
}
times[s[i]]=i;
bool f=true;
for(int j=0;h[j];j++){if(h[j]!=s[i+j]){
f=false;
break;
}
}
if(f)p[++cnt]=i;
}
if(cnt>2)printf("NO");
else {printf("YES
");
if(cnt==0) {if(fu==true)printf("%d %d",p01+1,p02+1);
else printf("1 2");
}
else if(cnt==1)printf("%d %d",p[1]+1,p[1]+2);
else printf("%d %d",p[1]+2,p[2]+1);
}
return 0;
}
C.
by GavinZheng
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int ans=1<<31-1;
int a,b,c;cin>>a>>b>>c;
int lr,lg;cin>>lr>>lg;
if(a+c>lr)ans=min(ans,lr);
if(b+c>lg)ans=min(ans,lg);
if(ans==(1<<31-1))ans=a+b+c;
cout<<ans;
return 0;
}
D.
by Han Tianxin
#include <cstdio>
int gcd(int a, int b) {if (b == 0) return a;
return gcd(b, a % b);
}
int main()
{
int n, x, i, k, all;
scanf("%d %d %d", &n, &x, &all);
for (i = 1; i < n; i++) {scanf("%d", &k);
all = gcd(all, k);
}
printf("%s", (x % all == 0) ? "YES" : "NO");
return 0;
}
G.
by sshwy
#include<bits/stdc++.h>
#define N 200005
using namespace std;
int n,m;
string s[N];
char c[200000];
int pre[N];
int main(){scanf("%d",&n);
for(int i=1;i<=n;i++){scanf("%s",c);
s[i]=c;
}
scanf("%d",&m);
for(int i=1,x,y;i<=m;i++){scanf("%d%d",&x,&y);
s[x]=s[y],pre[x]=pre[y]+1;
}
for(int i=1;i<=pre[1];i++)printf("I_love_");
cout<<s[1];
return 0;
}
H.
by GavinZheng
#include<iostream>
#include<cstdio>
#include<algorithm>
#define maxn 1050
using namespace std;
int map[maxn][maxn],n,m;
struct gg{int x,y,va;}data[maxn*maxn];
int tot=0;int ans1=0;int ans2=0;
int line1[4],line2[4];
bool com(gg x,gg y){return x.va>y.va;
}
void solve1(){//lie
bool check[maxn][maxn]={{0}};
line1[2]=data[1].y;
for(int i=1;i<=n;i++){check[i][data[1].y]=1;
}
for(int i=2;i<=tot;i++){if(check[data[i].x][data[i].y]==0){line1[1]=data[i].x;
for(int h=1;h<=m;h++){check[data[i].x][h]=1;
}
break;
}
else continue;
}
for(int i=1;i<=n;i++){for(int h=1;h<=m;h++){if(check[i][h]==0) ans1=max(ans1,map[i][h]);
}
}
return;
}
void solve2(){//hang
bool check[maxn][maxn]={{0}};
line2[1]=data[1].x;
for(int i=1;i<=m;i++){check[data[1].x][i]=1;
}
for(int i=2;i<=tot;i++){if(check[data[i].x][data[i].y]==0){line2[2]=data[i].y;
for(int h=1;h<=n;h++){check[h][data[i].y]=1;
}
break;
}
else continue;
}
for(int i=1;i<=n;i++){for(int h=1;h<=m;h++){if(check[i][h]==0) ans2=max(ans2,map[i][h]);
}
}
return;
}
int main()
{scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){for(int h=1;h<=m;h++){scanf("%d",&map[i][h]);
data[++tot].va=map[i][h];
data[tot].x=i;data[tot].y=h;
}
}
sort(data+1,data+1+tot,com);
solve1();//lie
solve2();//hang
if(ans1<ans2){cout<<line1[1]<<' '<<line1[2];
}
else{cout<<line2[1]<<' '<<line2[2];
}
return 0;
}
M.
by sshwy
#include<bits/stdc++.h>
#define N 200005
using namespace std;
typedef long long ll;
int a[N],fin[N],fnt;
int n,lf;
int ans[N][2],ant;
int main()
{scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
for(int i=n;i>=1;i--){if(a[i]==0){fin[++fnt]=i;
}
else {if(fnt-a[i]<0){//no people to kill
printf("NO");
return 0;
}
for(int j=0;j<a[i];j++)ans[++ant][0]=i,ans[ant][1]=fin[fnt-j];
fnt-=a[i];
fin[++fnt]=i;//a[i] is finished
}
}
printf("YES
");
for(int i=1;i<=ant;i++)printf("%d %d
",ans[i][0],ans[i][1]);
return 0;
}