[非题解]Codeforces Round #454 (Div. 2) D. Seating of Students

来源:互联网 发布:单片机体温计课程设计 编辑:程序博客网 时间:2024/05/30 04:44

这题是错的…虽然不知道哪里错了,还是贴下来吧…

#include <iostream>#include <queue>using namespace std;queue<int> outp[100000];void solve(int n,int m){    int tem,i,j;    for(i=1;i<=n;i++){        tem=(i-1)*m+1;        if(i&1)tem+=!(tem&1);        else tem+=(tem&1);        for(j=1;j<=m;j++){            outp[i].push(tem);tem+=2;            if(j==(m+1)/2){                tem=(i-1)*m+1;                if(i&1)tem+=tem&1;                else tem+=!(tem&1);            }        }    }}void prt(int m,int n){    int i,j;    if(n<=m){        for(i=1;i<=n;i++){            while(!outp[i].empty())cout<<outp[i].front()<<" ",outp[i].pop();            if(i!=n)cout<<endl;        }    }else{        while(!outp[1].empty()){            for(i=1;i<=m;i++){                cout<<outp[i].front()<<" ",outp[i].pop();            }            if(!outp[1].empty())cout<<endl;        }    }}int main(){    std::ios::sync_with_stdio(false);    int n,m,i,j,num=-1,mn,flag=1;    cin>>n>>m;mn=m*n;    if(1<mn&&mn<9&&m<=3&&n<=3)cout<<"NO";    else {        cout<<"YES"<<endl;        if(m==1&&n==1)cout<<"1";        else if(m==2&&n==4)cout<<"2 3"<<endl<<"7 6"<<endl<<"4 1"<<endl<<"5 8";        else if(m==4&&n==2)cout<<"5 4 7 2"<<endl<<"3 6 1 8";        else if(m==3&&n==3)cout<<"6 1 8"<<endl<<"7 5 3"<<endl<<"2 9 4";        else if(m==1&&n==4)cout<<"2\n4\n1\n3";        else if(m==4&&n==1)cout<<"2 4 1 3";        else{            if(m<n)solve(m,n);else solve(n,m);            prt(m,n);        }    }}
阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 被窝影院 连袜裤 行车记录仪什么牌子好 血肉之躯 血糖高的症状 英雄血战 高血压 血压高是什么原因引起的 血压高怎么调理 正常血压 血压 蟑螂图片 螃蟹怎么蒸 螃蟹怎么洗 清蒸螃蟹 小蝌蚪 蜈蚣 蛋糕的做法 电饭锅蛋糕 蛊惑主妇 蚌埠 虫草花的功效与作用 褥虫 六月观主 太虚化龙篇 虎山行 蘑菇头 藕粉的作用与功效 藏獒 重大博物馆藏赝品 薯条的做法 薏米 薄荷 蔡萝莉 蓝鲸 蓝色生死恋 蓝牙耳机什么牌子的好 清蒸鱼 水蒸蛋 蒸鸡蛋羹的做法 蒙面唱将 蒋英