• <fieldset id="8imwq"><menu id="8imwq"></menu></fieldset>
  • <bdo id="8imwq"><input id="8imwq"></input></bdo>
    最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
    問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
    當前位置: 首頁 - 科技 - 知識百科 - 正文

    CodeforcesRound#252(Div.2)-C,D_html/css

    來源:懂視網 責編:小采 時間:2020-11-27 15:53:46
    文檔

    CodeforcesRound#252(Div.2)-C,D_html/css

    CodeforcesRound#252(Div.2)-C,D_html/css_WEB-ITnose:C題就是一個簡單的模擬,首先給每個人兩個。然后把剩下的都給一個人就好了。 給的時候蛇形給。 #include#include#include#include#include#includeusing namespace std;#define LL __int64#define maxn 330000int ma
    推薦度:
    導讀CodeforcesRound#252(Div.2)-C,D_html/css_WEB-ITnose:C題就是一個簡單的模擬,首先給每個人兩個。然后把剩下的都給一個人就好了。 給的時候蛇形給。 #include#include#include#include#include#includeusing namespace std;#define LL __int64#define maxn 330000int ma

    C題就是一個簡單的模擬,首先給每個人兩個。然后把剩下的都給一個人就好了。

    給的時候蛇形給。

    #include#include#include#include#include#includeusing namespace std;#define LL __int64#define maxn 330000int main(){ int n,m,k; while(~scanf("%d%d%d",&n,&m,&k)) { int leap=1; int stx=1; int sty=1; int ms=n*m-(k*2)+2; printf("%d",ms); while(ms--) { printf(" %d %d",stx,sty); sty+=leap; if(sty<1||sty>m) { if(sty<1)sty=1; if(sty>m)sty=m; stx++;leap=-leap; } } cout<m) { if(sty<1)sty=1; if(sty>m)sty=m; stx++;leap=-leap; } printf("%d %d\n",stx,sty); sty+=leap; if(sty<1||sty>m) { if(sty<1)sty=1; if(sty>m)sty=m; stx++;leap=-leap; } } } return 0;}
    D:首先根據環,把每一個環分成一組。記錄下此時至少需要交換all次,才能回歸到恒等排列。

    1,如果all大于p。那么我們就應該把all減少。

    對于一個環,任意兩個點交換都可以把環分成兩份,all-1;

    對于每次減少,我們尋找環的最小值最小的環,然后在這個環中尋找最小值,然后交換這兩個點。

    2,如果all小于p。那么我們應該把all增大。

    那么我們就可以把1號節點和任意節點交換,來達到增大all的目的。

    注意,1號節點不和本身的環交換。并且1號節點和任意一個環只交換一次。

    #include#include#include#include#include#includeusing namespace std;#define LL __int64#define maxn 3300int a[maxn];int b[maxn];int vis[maxn];vectorvec;vector< vector >ans;struct list{ int x,y;} node;vectorpr;bool cmp(vectora,vectorb){ return a[0]b.x; }}tt;priority_queueque;int main(){ int n,m; while(~scanf("%d",&n)) { for(int i=1; i<=n; i++) { scanf("%d",&a[i]); b[i]=a[i]; } scanf("%d",&m); memset(vis,0,sizeof(vis)); vec.clear(); ans.clear(); int all=0; for(int i=1; i<=n; i++) { if(vis[i])continue; int j=i; vec.clear(); while(b[j]!=j&&vis[j]==0) { vec.push_back(j); vis[j]=1; j=b[j]; } if(vec.size()) { // sort(vec.begin(),vec.end()); ans.push_back(vec); all+=vec.size()-1; } } sort(ans.begin(),ans.end(),cmp); pr.clear(); if(all<=m) { all=m-all; if(ans.size()==0) { node.x=1; for(int i=2; i<=all+1; i++) { node.y=i; pr.push_back(node); } } else { node.x=1; int j=0; if(ans[0][0]==1)j++; for(int i=2; i<=n&&all>0; i++) { if(b[i]==i) { all--; node.y=i; pr.push_back(node); } if(ans.size()>j&&ans[j][0]==i) { all--; node.y=i; j++; pr.push_back(node); } } } } else { int qian=all; all=all-m; int i=0; while(!que.empty())que.pop(); for(i=0;i0;j++) { if(minn>ans[i][j]) { minn=ans[i][j]; st=j; } } node.y=minn; all--; pr.push_back(node); vec.clear(); minn=9999; vec.push_back(ans[i][st]); for(int j=1;j1) { ans.push_back(vec); tt.index=ans.size()-1; tt.x=vec[0]; que.push(tt); } vec.clear(); vec.push_back(ans[i][0]); for(int j=st+1;j1) { ans[i]=vec; tt.index=i; tt.x=vec[0]; que.push(tt); } i++; } } cout<

    聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

    文檔

    CodeforcesRound#252(Div.2)-C,D_html/css

    CodeforcesRound#252(Div.2)-C,D_html/css_WEB-ITnose:C題就是一個簡單的模擬,首先給每個人兩個。然后把剩下的都給一個人就好了。 給的時候蛇形給。 #include#include#include#include#include#includeusing namespace std;#define LL __int64#define maxn 330000int ma
    推薦度:
    標簽: d div round
    • 熱門焦點

    最新推薦

    猜你喜歡

    熱門推薦

    專題
    Top
    主站蜘蛛池模板: 精品九九久久国内精品| 国产精品自在在线午夜福利| 四虎精品影院永久在线播放| 亚洲AV无码乱码精品国产| 久久亚洲精品视频| 久久九九精品99国产精品| 久久久精品久久久久久 | 91精品视频网站| 日韩欧精品无码视频无删节| 久久久久这里只有精品 | 9191精品国产免费久久| 99久久精品国产麻豆| 精品无码一区二区三区爱欲 | 国产精品 91 第一页| 精品久久久久久中文字幕| 精品一区二区三区自拍图片区| 亚洲国产精品人人做人人爱| 精品国产污污免费网站入口在线| 久久这里只有精品久久| 97久久国产亚洲精品超碰热| 欧美肥屁VIDEOSSEX精品| 亚洲日韩精品射精日| 亚洲第一永久AV网站久久精品男人的天堂AV | 久久亚洲国产精品五月天婷| 99久久国产综合精品网成人影院| 国产欧美久久久精品| 精品国产污污免费网站| 久久精品国产精品青草| 日本久久久精品中文字幕| 久久精品中文字幕久久| 欧美日激情日韩精品| MM1313亚洲精品无码| 国产在线观看一区二区三区精品 | 亚洲欧美国产∧v精品综合网| 亚洲国产高清精品线久久| 亚洲精品和日本精品| 亚洲午夜国产精品无码| 无码国产精品一区二区免费vr| 无码精品人妻一区二区三区人妻斩| 亚洲精品无码专区在线在线播放| 亚洲精品乱码久久久久久蜜桃不卡 |