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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

联系 Contact

發(fā)布時間:2024/10/5 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 联系 Contact 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

https://www.luogu.org/problemnew/show/P2724

題意:輸出多少頻率最多的序列。

題解:

輸出

  • 輸出完頻率要換行。
  • 輸出6個序列要換行。
  • 輸出完序列要換行。
  • 如果該頻率的序列剛好是6個的話只要換一次行。
  • 每行第一個序列之前不能有空格。
  • 每行最后一個序列之后不能有空格。
  • 排序

  • 頻率高的在前。
  • 頻率一樣時,位數(shù)少的在前。
  • 位數(shù)也一樣時,字典序小的在前。
  • C++版本一

    題解:map+vector+sort+枚舉

    /* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=200000+10; const int M=200000; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,p,l,r,u,v; int ans,cnt,flag,sum; string str,temp; map<string,int>mp; vector<string>V[N]; struct node{string str;int cnt;bool operator <(const node &S)const{if(cnt==S.cnt){if(str.size()==S.str.size()){return str<S.str;}return str.size()<S.str.size();}return cnt>S.cnt;}}e[N]; int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d%d%d",&n,&m,&k);while(cin>>temp){str+=temp;}cin>>str;for(int i=n;i<=m;i++){for(int j=0;i+j<=str.size();j++){string temp=str.substr(j,i);if(!mp[temp]){mp[temp]=++sum;e[sum].str=temp;}int id=mp[temp];e[id].cnt++;}}sort(e+1,e+sum+1);for(int i=1;i<=sum;i++){V[e[i].cnt].push_back(e[i].str);}for(int i=M;i>0&&cnt<k;i--){if(V[i].size()){cout<<i<<endl;cnt++;for(int j=0;j<V[i].size();j++){cout<<V[i][j]<<((j+1)%6==0||j==V[i].size()-1?'\n':' ');}}}//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

    C++版本二

    題解:狀態(tài)壓縮+DP

    /* ID: K wth PROG: contact LANG: C++ */ #include <bits/stdc++.h> using namespace std; char s[300000]; int hz [1<<13]; int l,r,n,m; struct note {int x;int y;int z;note(int x=0,int y=0,int z=0):x(x),y(y),z(z) {}; }; vector<note> v; bool cmp(note x,note y) {return x.y>y.y || x.y==y.y && (x.z<y.z || x.z==y.z && x.x<y.x); } void work(int x,int lon) {int mod=(1<<lon)-1;while(lon+1){putchar('0'+(x>>lon));x&=mod;mod>>=1;lon--;} } int main() {scanf("%d %d %d",&l,&r,&n);for(int i=0;scanf("\n%s",s+i)!=-1;i+=80) ; // printf("%s\n\n",s);return 0;r=min(m=strlen(s) , r);for(int i=0,zhi=0;i<r;i++){zhi=(zhi<<1)|(s[i]-'0');if(i>=l-1){int mod=(1<<(i+1))-1,z=zhi;memset(hz,0,sizeof(hz));hz[z]=1;for(int j=i+1;j<m;j++){z=((z<<1)|(s[j]-'0'))&mod;hz[z]++;}for(int j=0;j<=mod;j++)if(hz[j])v.push_back(note(j,hz[j],i));}}sort(v.begin(),v.end(),cmp);for(int i=0,last=1<<18,j=0,have=0;i<v.size();i++,have++){// cout<<"test:"<<v[i].x<<v[i].y<<v[i].z<<endl;if(v[i].y<last){last=v[i].y;if(j++==n || !last) break;if(i) putchar('\n');have=0;printf("%d\n",last);}else if(have==6) putchar('\n'),have=0;else putchar(' ');work(v[i].x,v[i].z);}putchar('\n'); }

    ?

    總結(jié)

    以上是生活随笔為你收集整理的联系 Contact的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。