这个月摆的有点过了...就写一些水题找找手感吧...
1.6:当时同学让我做的题感觉有点思维,整体思路:前面的种类*2-那些前两个都是放的种类,至于怎么确定前面两个是否都放了东西,拿前三个坑已经放好了有7种举例,第四个坑如果没有要求的话肯定有7*2种放法,要么后面加1要么加0,但是因为不能连续三个,所以在前两个都是1,的情况下要减去一种情况(因为这样只能放0了),但是在确定有几个前两个1的时候,举例再算第四个坑的时候。
#include<stdio.h>
long long dp[100];
int main(){
int n;
;
while(~scanf("%d",&n))
{
dp[0]=1;
for(int i=1;i<=n;i++){
if(i<=2) dp[i]=dp[i-1]*2;
else if(i==3) dp[i]=dp[i-1]*2-1;
else dp[i]=dp[i-1]*2-dp[i-4];
}
printf("%lld\n",dp[n]);
}
}
1.7:
vj周赛:芝士周赛 - Virtual Judge (csgrandeur.cn)
F:
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
typedef long long ll;
using namespace std;
ll gan[200005];
int main(){
ll n,k;
cin>>n>>k;
map<ll,ll>mp;
queue<ll>q;
ll sum=0,a;
for(int i=0;i<n;i++){
cin>>a;
if(mp[a]==0&&sum<k){
q.push(a);
sum++;
mp[a]=1;
}
else if(mp[a]==0&&sum==k){
mp[a]=1;
q.push(a);
a=q.front();
q.pop();
mp[a]=0;
}
}
for(int i=sum;i>0;i--){
gan[i]=q.front();
q.pop();
}
cout<<sum<<endl;
for(int i=1;i<=sum;i++){
cout<<gan[i]<<" ";
}
}
1.8:
div2:Dashboard - Educational Codeforces Round 141 (Rated for Div. 2) - Codeforces
A:
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
typedef long long ll;
using namespace std;
ll a[100];
int main(){
ll t;
cin>>t;
while(t--){
ll n;
cin>>n;
ll max=0;
ll cf=0;
for(int i=1;i<=n;i++){
cin>>a[i];
if(a[i]==a[i-1]){
cf++;
if(cf>max)max=cf;
}
else{
cf=1;
if(cf>max)max=cf;
}
}
if(cf>max)max=cf;
if(max==n) cout<<"NO"<<endl;
else {
cout<<"YES"<<endl;
if(a[n]==a[n-1]){
cout<<a[n]<<" "<<a[1]<<" ";
for(int i=n-1;i>1;i--) cout<<a[i]<<" ";
}
else {
for(int i=n;i>0;i--){
cout<<a[i]<<" ";
}
}
cout<<endl;
}
}
}
B:
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
typedef long long ll;
using namespace std;
ll n;
ll a[2505];
int main(){
ll t;
cin>>t;
while(t--){
cin>>n;
ll p=1;
ll ans=1;
for(int i=1;i<=n*n/2;i++){
a[ans]=i;
a[ans+1]=n*n-i+1;
ans+=2;
}
if(n%2==1){
a[ans]=n*n/2+1;
ans++;
}
for(int i=0;i<n;i++){
if(p==1){
for(int j=1;j<=n;j++){
cout<<a[i*n+j]<<" ";
}
cout<<endl;
p=-p;
}
else{
p=-p;
for(int j=1;j<=n;j++){
cout<<a[i*n+n-j+1]<<" ";
}
cout<<endl;
}
}
}
}
1.9:
1.10:
1.11:
1.12:
1.13:
1.14:
1.15:
1.16:
牛客训练营1:https://ac.nowcoder.com/acm/contest/46800
这次好像手感不是很好,也可能是心里问题有两题卡住了然后就打得很差....
C:
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
typedef long long ll;
using namespace std;
ll a[100005];
int cmp(ll x,ll y){
return x>y;
}
int main(){
ll t;
cin>>t;
while(t--){
ll n,tmp=0;
cin>>n;
for(int i=0;i<n;i++){cin>>a[i];
if(a[i]==0) tmp++;}
cout<<n-tmp<<endl;
}
}
1.17:牛客训练营1补题。补题之后到了7题的做题数。
M:
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
typedef long long ll;
using namespace std;
double dp[505][505];
int main(){
ll n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=0;j<=m;j++){
for(int k=0;k<=j;k++){
dp[i][j]=max(dp[i][j],dp[i-1][j-k]+k*1.0/(m-j+k));
}
}
}
double ma=0;
for(int i=1;i<=n;i++){
for(int j=0;j<=m;j++){
if(dp[i][j]>ma)ma=dp[i][j];
}
}
printf("%.9f\n",ma);
}
1.18:牛客训练营2:https://ac.nowcoder.com/acm/contest/46810#question
这次比1状态好点...做了四题,后面做不出就直接走了...
D:
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
typedef long long ll;
using namespace std;
ll hh[200005];
ll a[200005];
int main(){
ll n;
cin>>n;
hh[1]=1;
for(int i=2;i<=n;i++){
ll tmp;
cin>>tmp;
hh[i]=hh[tmp]+1;
}
for(int i=1;i<=n;i++)cin>>a[i];
sort(hh+1,hh+n+1);
sort(a+1,a+1+n);
ll sum=0;
for(int i=1;i<=n;i++){
sum+=hh[i]*a[i];
}
cout<<sum<<endl;
}
1.19:
1.20:牛客训练赛3:https://ac.nowcoder.com/acm/contest/46811
这次就打了两个小时就走了...
D:
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
typedef long long ll;
using namespace std;
int main(){
ll n;
cin>>n;
if(n%2==0) cout<<"kou";
else cout<<"yukari";
}
1.21:牛客3补题:
C:
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
typedef long long ll;
using namespace std;
int main(){
ll n;
cin>>n;
if(n==7||n<4)cout<<"-1";
else if(n%4==0){
for(int i=1;i<=n;i+=4){
cout<<i+2<<" "<<i+3<<" "<<i<<" "<<i+1<< " ";
}
}
else if(n%4==1){
cout<<"3 4 5 1 2 ";
for (int i=6;i<=n;i+=4){
cout<<i+2<<" "<<i+3<<" "<<i<<" "<<i+1<<" ";
}
}
else if(n%4==2){
cout<<"3 5 1 6 2 4 ";
for(int i=7;i<=n;i+=4){
cout<<i+2<<" "<<i+3<<" "<<i<<" "<<i+1<< " ";
}
}
else if(n%4==3){
cout<< "3 4 1 6 2 8 5 10 11 7 9 ";
for(int i=12;i<=n;i+=4){
cout<<i+2<<" "<<i+3<<" "<<i<<" "<<i+1<<" ";
}
}
}
1.22:
1.23:
1.24:
1.25:
1.26:
1.27:
cf的div3:Dashboard - Codeforces Round #847 (Div. 3) - Codeforces
D:
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
typedef long long ll;
using namespace std;
struct hh{
ll shu,c;
};
int cmp(hh x,hh y){
if(x.c==y.c) return x.shu<y.shu;
return x.c<y.c;
}
hh a[200005];
void solve(){
ll n;
ll ans=0;
cin>>n;
map<ll,ll>mp;
for(int i=0;i<n;i++){
ll tmp;
cin>>tmp;
a[i].shu=tmp;
mp[tmp]++;
a[i].c=mp[tmp];
}
sort(a,a+n,cmp);
for(int i=0;i<n-1;i++){
if(a[i].shu!=a[i+1].shu-1) ans++;
}
cout<<ans+1<<endl;
}
int main(){
ll t;
cin>>t;
while(t--){
solve();
}
}
1.28:
上海市一月赛:2023 年上海市大学生程序设计竞赛 - 一月赛 - ECNU Online Judge
A:
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
typedef long long ll;
using namespace std;
int main(){
map<ll,string>mp;
map<string,ll>mp2;
ll n;
cin>>n;
ll ans=n;
for(int i=0;i<n;i++){
string a,b;
cin>>a;
cin>>b;
mp[i]=a;
if(b!="No"){mp2[b]=1;mp2[a]=1;}
}
for(int i=0;i<n;i++){
if(mp2[mp[i]]==1)ans--;
}
cout<<ans<<endl;
}