Codeforces Global Round 7 总结
Posted mollnn
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Global Round 7 总结相关的知识,希望对你有一定的参考价值。
A
#include <bits/stdc++.h>
using namespace std;
signed main() {
int t,n;
ios::sync_with_stdio(false);
cin>>t;
while(t--) {
cin>>n;
if(n==1) {
cout<<-1<<endl;
}
else {
cout<<2;
for(int i=1;i<n;i++) cout<<3;
cout<<endl;
}
}
}
B
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1000005;
int n,a[N],b[N],c[N];
signed main() {
ios::sync_with_stdio(false);
cin>>n;
for(int i=1;i<=n;i++) {
cin>>b[i];
}
a[1]=b[1];
c[1]=0;
for(int i=2;i<=n;i++) {
c[i]=max(c[i-1],a[i-1]);
a[i]=b[i]+c[i];
}
for(int i=1;i<=n;i++) cout<<a[i]<<" ";
}
C
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 998244353;
const int N = 1000005;
int n,k,a[N],p[N];
struct item {
int id,x;
bool operator < (const item &b) const {
return x<b.x;
}
} b[N];
signed main() {
ios::sync_with_stdio(false);
cin>>n>>k;
for(int i=1;i<=n;i++) cin>>a[i], b[i]={i,a[i]};
sort(b+1,b+n+1);
int ans=0;
for(int i=n-k+1;i<=n;i++) {
ans+=b[i].x;
p[i-n+k]=b[i].id;
}
sort(p+1,p+k+1);
int tans=1;
for(int i=1;i<k;i++) tans=tans*(p[i+1]-p[i])%mod;
cout<<ans<<" "<<tans<<endl;
}
D
#include <bits/stdc++.h>
using namespace std;
// Input: str[] (0-index)
// Method: solve()
// Output: a[] (i -> i*2+1)
namespace man {
const int N = 4100005;
char str[N], s[N<<1];
int a[N<<1];
int manacher(int len){
a[0] = 0;
int ans = 0, j;
for(int i = 0; i < len; ){
while(i-a[i]>0 && s[i+a[i]+1]==s[i-a[i]-1])
a[i]++;
if(ans < a[i])ans = a[i];
j = i+1;
while(j<=i+a[i] && i-a[i]!=i+i-j-a[i+i-j]){
a[j] = min(a[i+i-j], i+a[i]-j);
j++;
}
a[j] = max(i+a[i]-j, 0);
i = j;
}
return ans;
}
int solve(){
int len;
len = 2*strlen(str)+1;
for(int i=0;i<=2*len;i++) a[i]=0;
for(int i = 0; str[i] != '