• <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
    主站蜘蛛池模板: 日批日出水久久亚洲精品tv| 久久发布国产伦子伦精品| 国产精品久久久久9999| 久久久久无码国产精品不卡| 国产在线拍揄自揄视精品不卡| 真实国产乱子伦精品一区二区三区 | 亚洲综合一区二区国产精品| 四虎国产精品永久在线| 欧美成人精品一区二三区在线观看| 94久久国产乱子伦精品免费| 99在线精品视频在线观看| 色欲国产麻豆一精品一AV一免费 | 日韩精品一区二区三区色欲AV| 久久久久久久久久免免费精品| 99亚洲精品视频| 亚洲精品电影网| 精品久久香蕉国产线看观看亚洲 | 久久丫精品国产亚洲av| 自拍偷在线精品自拍偷| 日韩熟女精品一区二区三区| 国产日韩高清三级精品人成| 国产成人精品福利网站在线观看| 国内精品一级毛片免费看| WWW国产精品内射老师| 国产亚洲欧美精品永久| 精品人伦一区二区三区潘金莲| 亚洲AV永久无码精品一百度影院| 中文字幕精品久久| 在线精品亚洲一区二区小说| 无翼乌无遮挡全彩老师挤奶爱爱帝国综合社区精品 | 国产精品亚洲片在线| 日韩精品少妇无码受不了| 亚洲一区精品无码| 无码精品黑人一区二区三区| 亚洲国产精品无码久久久不卡| 亚洲AV永久无码精品| 日韩精品无码免费一区二区三区 | 视频二区国产精品职场同事| 欧美亚洲国产精品第一页| 亚洲一区精品中文字幕| 国产精品嫩草影院久久|