跳到正文

个人记录

4.17比赛总结

Ethan0824约 5 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年2月15日
篇幅
约 5 分钟

版本

  1. v1当前

总结:

P2089 烤鸡:

错误:其实这道题是水题,思路也没问题,but数组开小了。

原本我算了3^10=59049,

但是数组写成了5e3(a[5000][10]);

所以RE了。

所以直接复制上代码:

C++
  #include<bits/stdc++.h>
    using namespace std;
    const int N=1e5+5;
    long long n,x,a[N][10],o=1;
    bool f=0;
    int main(){
  	cin>>n;
    if(n>30){
        cout<<0;
        return 0;
    }
for(int i1=1;i1<=3;i1++){
	for(int i2=1;i2<=3;i2++){
		for(int i3=1;i3<=3;i3++){
			for(int i4=1;i4<=3;i4++){
				for(int i5=1;i5<=3;i5++){
					for(int i6=1;i6<=3;i6++){
						for(int i7=1;i7<=3;i7++){
							for(int i8=1;i8<=3;i8++){
								for(int i9=1;i9<=3;i9++){
                                        int i10=n-(i1+i2+i3+i4+i5+i6+i7+i8+i9);
										if(i1+i2+i3+i4+i5+i6+i7+i8+i9+i10==n&&i10>=1&&i10<=3){
											a[o][1]=i1;
                                            a[o][2]=i2;
                                            a[o][3]=i3;
                                            a[o][4]=i4;
                                            a[o][5]=i5;
                                            a[o][6]=i6;
                                            a[o][7]=i7;
                                            a[o][8]=i8;
                                            a[o][9]=i9;
                                            a[o][10]=i10;
											f=1;
                                            x++;
                                            o++;

									}
								}
							}
						}
					}
				}
			}
		}
	}
}
cout<<x<<endl;
for(int i=1;i<o;i++){
    for(int j=1;j<=10;j++)cout<<a[i][j]<<" ";
    cout<<endl;
}
if(f==0)cout<<0;
return 0;

}

P3913 车的攻击

错误:别说了,没学过map的我十分无助。

所以再次直接复制上代码:

C++
  #include<bits/stdc++.h>
  using namespace std;
  const int N=1e8+10000000;
  long long n,x,y,m,h[N],l[N],ans,sum;
  unordered_map<int,int>mp1;
  unordered_map<int,int>mp2;
  int main(){
cin>>n>>m;
for(int i=1;i<=m;i++){
	cin>>x>>y;
    if(mp1[x]==0){
       mp1[x]=1;
        ans++;
    }
   if(mp2[y]==0){
       mp2[y]=1;
       sum++;
   }
}

cout<<(ans*n)+(sum*n)-ans*sum;
return 0;

}

(注意map要开unordered呦~~)

原文