日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Educational Codeforces Round 107 (Rated for Div. 2)

發布時間:2023/12/3 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Educational Codeforces Round 107 (Rated for Div. 2) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Educational Codeforces Round 107 (Rated for Div. 2)

題號題目知識點
AReview Site簽到
BGCD Length思維+構造
CYet Another Card Deck思維
DMin Cost String構造題
EColorings and Dominoes思維題,構造題
FChainword
GChips on a Board

A

題意:

有3種評論員,第一個會給電影贊,第二個會給電影踩,第三個如果當前踩的數量大于贊,就會給贊,否則給踩
現在有n個評論員,問贊最多是多少

題解:

把贊的評論員全部放前面,第三種放中間,踩的最后
贊的數量+中立-踩

代碼:

#include<bits/stdc++.h> typedef long long ll; using namespace std; inline int read(){int s=0,w=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();//s=(s<<3)+(s<<1)+(ch^48);return s*w; } const int maxn=60; int a[maxn]; int main() {int t;cin>>t;while(t--){int n;cin>>n;int sum=0; int tot=0;for(int i=1;i<=n;i++){int x;cin>>x;if(x==1||x==3){sum++;}}cout<<sum<<endl;}return 0; } /* 反對>贊同 × 贊同>=反對 4 1 2 3 1 2 3 5 1 1 1 1 1 3 3 3 2*/

C

題意:

一個序列,每次給出一個x,輸出第一個出現x的坐標,并將其放到最前面,其他數順位,有q個這樣的操作

題解:

雖然數會有重復,但是只需要記錄第一個出現的就行,后面出現的沒影響,然后用數組模擬過程即可
a和t的范圍很小,直接暴力就行

代碼:

#include<bits/stdc++.h> typedef long long ll; using namespace std; inline int read(){int s=0,w=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();//s=(s<<3)+(s<<1)+(ch^48);return s*w; } const int maxn=800; int b[maxn]; int v[maxn]; int main() {int n,q;cin>>n>>q;int tot=0;for(int i=1;i<=n;i++){int x;cin>>x;if(b[x]!=0)continue;v[++tot]=x;//順序存數 b[x]=i;//x的位置 }int x;for(int i=1;i<=q;i++){ cin>>x;cout<<b[x]<<" ";int pos;for(int i=1;i<=tot;i++){if(v[i]==x){pos=i;break;}}for(int i=1;i<pos;i++){b[v[i]]++;}for(int i=pos;i>=2;i--){v[i]=v[i-1];//往后移動一次 }b[x]=1;v[1]=x;}return 0; }

總結

以上是生活随笔為你收集整理的Educational Codeforces Round 107 (Rated for Div. 2)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。