比赛链接:ABC366
这么 rz 的题我就然还挂了 2 发,wssb。
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,T,A;
cin>>N>>T>>A;
if(T>=(N/2+1) || T>=(N/2+1))
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
return 0;
}
很烦,烦的不得了。我甚至先过 C 再过的这题。尤其是行末不能有 * 特别坑。
#include <bits/stdc++.h>
using namespace std;
char S[105][105];
bool check(int x,int y){
for(int i=x;i>0;i--){
if(S[i][y]!=' ')
return true;
}
return false;
}
int main(){
for(int i=1;i<=105;i++){
for(int j=0;j<105;j++)
S[i][j]=' ';
}
int N,M=0;
cin>>N;
for(int i=1;i<=N;i++){
string s;
cin>>s;
M=max(M,(int)s.size());
for(int j=0;j<s.size();j++)
S[i][j]=s[j];
}
for(int i=0;i<M;i++){
for(int j=N;j>0;j--){
if(S[j][i]!=' ')
cout<<S[j][i];
else if(check(j,i))
cout<<'*';
}
cout<<endl;
}
return 0;
}
暴力肯定 TLE,开个桶记录一下就好了(注意到 )
#include <bits/stdc++.h>
using namespace std;
int buc[MAX],ans=0;
int main(){
int Q;
cin>>Q;
while(Q--){
int opt;
cin>>opt;
if(opt==1){
int x;
cin>>x;
if(!buc[x])
ans++;
buc[x]++;
}
if(opt==2){
int x;
cin>>x;
buc[x]--;
if(!buc[x])
ans--;
}
if(opt==3)
cout<<ans<<endl;
}
return 0;
}
三维前缀和,启动!!!!!
#include<bits/stdc++.h>
using namespace std;
int sum[maxn][maxn][maxn],A[maxn][maxn][maxn];
int main(){
int N;
cin>>N;
for(int x=1;x<=N;x++){
for(int y=1;y<=N;y++){
for(int z=1;z<=N;z++)
cin>>A[x][y][z];
}
}
for(int i=1;i<=N;i++){
for(int j=1;j<=N;j++){
for(int k=1;k<=N;k++)
sum[i][j][k]=sum[i-1][j][k]+sum[i][j-1][k]+sum[i][j][k-1]-sum[i-1][j-1][k]-sum[i-1][j][k-1]-sum[i][j-1][k-1]+sum[i-1][j-1][k-1]+A[i][j][k];
}
}
int Q;
cin>>Q;
while(Q--){
int lx,rx,ly,ry,lz,rz;
cin>>lx>>rx>>ly>>ry>>lz>>rz;
cout<<sum[rx][ry][rz]-sum[lx-1][ry][rz]-sum[rx][ly-1][rz]-sum[rx][ry][lz-1]+sum[lx-1][ly-1][rz]+sum[lx-1][ry][lz-1]+sum[rx][ly-1][lz-1]-sum[lx-1][ly-1][lz-1]<<endl;
}
return 0;
}
又双叒叕上分了,好耶!\(^o^)/~
闲话:8/11 晚上的 ARC182 太难辣,A 就 500pts 了,结果一题没做 rk. 1597,还上分了!NB
友情提醒:不要Ctrl C+Ctrl V