<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      sudoku

      
      

      瞎寫個(gè)數(shù)獨(dú)生成器,可選擇難度

      #include <bits/stdc++.h>
      
      using namespace std ;
      
      int orign_map[10][10],ans_map[10][10];
      int ans_cnt ; 
      int pos_x[100],pos_y[100];
      bool buc_h[10][10],buc_l[10][10],buc_blc[4][4][10];
      
      
      void dfs( int dep , int tot ){
          if ( ans_cnt >= 2 ) return ;
          if ( dep==tot+1 ){
              ++ ans_cnt ; 
              return ;
          }
          for ( int i=1 ; i<=9 ; ++i ) {
              if( !buc_h[pos_x[dep]][i] && !buc_l[pos_y[dep]][i]&&!buc_blc[(pos_x[dep]-1)/3+1][(pos_y[dep]-1)/3+1][i]) {
                  ans_map[pos_x[dep]][pos_y[dep]] = i ;
                  buc_h[pos_x[dep]][i] = true;
                  buc_l[pos_y[dep]][i] = true;
                  buc_blc[(pos_x[dep]-1)/3+1][(pos_y[dep]-1)/3+1][i] = true;
                  dfs( dep+1 , tot ) ; 
                  buc_h[pos_x[dep]][i] = false;
                  buc_l[pos_y[dep]][i] = false;
                  buc_blc[(pos_x[dep]-1)/3+1][(pos_y[dep]-1)/3+1][i] = false;
                  ans_map[pos_x[dep]][pos_y[dep]] = 0 ;
              }
          }
      }
      
      void generateOriginalMap(){
          int order[]={0,1,2,3,4,5,6,7,8,9};
          srand(time(NULL));
          random_shuffle(order+1,order+10);
          for( int i=4 ; i<=6 ; ++i ) for ( int j=4 ; j<=6 ; ++j ) orign_map[i][j] = order[(i-4)*3+j-3];
          for (int i=4 ; i<=6 ; ++i ) for ( int j=1 ; j<=3 ; ++j ) orign_map[i][j] = orign_map[(i+1)%3+4][j+3];
          for (int i=4 ; i<=6 ; ++i ) for ( int j=7 ; j<=9 ; ++j ) orign_map[i][j] = orign_map[(i+1)%3+4][j-6];
          for (int i=4 ; i<=6 ; ++i ) for ( int j=1 ; j<=3 ; ++j ) orign_map[j][i] = orign_map[j+3][(i+1)%3+4];
          for (int i=4 ; i<=6 ; ++i ) for ( int j=7 ; j<=9 ; ++j ) orign_map[j][i] = orign_map[j-6][(i+1)%3+4];
          for (int i=7 ; i<=9 ; ++i ) for ( int j=1 ; j<=3 ; ++j ) orign_map[j][i] = orign_map[j+3][(i+1)%3+7];
          for (int i=7 ; i<=9 ; ++i ) for ( int j=7 ; j<=9 ; ++j ) orign_map[j][i] = orign_map[j-6][(i+1)%3+7];    
          for (int i=1 ; i<=3 ; ++i ) for ( int j=1 ; j<=3 ; ++j ) orign_map[j][i] = orign_map[j+3][(i+1)%3+1];
          for (int i=1 ; i<=3 ; ++i ) for ( int j=7 ; j<=9 ; ++j ) orign_map[j][i] = orign_map[j-6][(i+1)%3+1];
      }
      
      void generateSolution(int difficulty){
          for(int i=1;i<=9;++i)for(int j=1;j<=9;++j)ans_map[i][j] = orign_map[i][j];
          srand(time(NULL));
          int numOfBlank = 0 , randIndex ;
          bool isUsed[100];
          memset(isUsed,false,sizeof(isUsed));
          memset(buc_h,1,sizeof(buc_h));
          memset(buc_l,1,sizeof(buc_l));
          memset(buc_blc,1,sizeof(buc_blc));
          while (difficulty) {
              ans_cnt = 0 ; randIndex = rand()%81+1;
              if( isUsed[randIndex] ) continue;
              else {
                  --difficulty;
                  isUsed[randIndex] = true;
      
                  int x = (randIndex-1)/9+1 , y = randIndex-(randIndex-1)/9*9; 
      
                  pos_x[++numOfBlank] = x ;
                  pos_y[numOfBlank] = y ;
                  buc_h[x][orign_map[x][y]] = false ;
                  buc_l[y][orign_map[x][y]] = false ;
                  buc_blc[(x-1)/3+1][(y-1)/3+1][orign_map[x][y]] = false;
      
                  ans_map[x][y]=0;
                  dfs( 1 , numOfBlank ) ;
      
                  if ( ans_cnt >= 2 ) {
                      // cout << "illegal!!!!!"<<endl;
                      --numOfBlank;
                      buc_h[x][orign_map[x][y]] = true ;
                      buc_l[y][orign_map[x][y]] = true ;
                      buc_blc[(x-1)/3+1][(y-1)/3+1][orign_map[x][y]] = true;
                      ans_map[x][y] = orign_map[x][y];
                  }
              }
          }
          
      }
      void output(){
          int blank=0;
          cout << "Problem:\n" ;
          for ( int i=1 ; i<=9 ; ++i ) {
              for ( int j=1 ; j<=9 ; ++j ) {
                  if(!ans_map[i][j]){
                      cout << "? ";
                      blank++;
                  }
                  else cout << ans_map[i][j] << " " ;
              }
              cout << endl ; 
          }
          cout << "Blank: " << blank << endl ; 
          cout << "-----------------\nAnswer:\n" ;
          for ( int i=1 ; i<=9 ; ++i ) {
              for ( int j=1 ; j<=9 ; ++j ) {
                  cout << orign_map[i][j] << " " ;
              }
              cout << endl ; 
          }
      }
      int in(){
          while(1){
              cout << "select difficulty:\n";
              cout << "1: easy     2: normal     3: hard     4:hard++\n" ;
              int a;cin >> a; 
              switch (a)
              {
              case 1:
                  return 35 ;
                  break;
              case 2:
                  return 40 ;
                  break;
              case 3:
                  return 55 ;
                  break;
              case 4:
                  return 68 ;
                  break ; 
              default:
                  cout << "illegal input\n" ;
                  break;
              }
          }
      }
      
      int main( ) {
          generateOriginalMap();
          generateSolution(in());
          output();
          return 0 ;
      }

       

      posted @ 2019-07-26 22:29  SHHHS  閱讀(340)  評(píng)論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 色综合 图片区 小说区| 午夜国产福利片在线观看| 午夜免费国产体验区免费的| 日本边添边摸边做边爱的网站| 97成人碰碰久久人人超级碰oo| 青春草公开在线视频日韩| 亚洲欧美人成人让影院| 看亚洲黄色不在线网占| av无码一区二区大桥久未| 日日噜噜夜夜狠狠视频| 东乌珠穆沁旗| 亚洲免费人成视频观看| 精品中文人妻中文字幕| 亚洲熟妇av一区二区三区宅男| 美女午夜福利视频一区二区| 久久精品国产中文字幕| 亚洲а∨天堂久久精品2021| 天天摸夜夜摸夜夜狠狠添| 亚洲中文字幕一二区日韩| 国产精品香港三级国产av| 久久av高潮av喷水av无码| 久久精品国产99亚洲精品| 人妻少妇精品无码专区二区| 午夜福利偷拍国语对白| 四虎国产精品久久免费精品| 国产AV大陆精品一区二区三区| 综合色天天久久| 亚洲综合黄色的在线观看| 99RE6在线观看国产精品| 人妻丰满熟妇av无码区| 自拍偷自拍亚洲精品情侣| 免费无码一区无码东京热| 欧洲精品码一区二区三区| 国产精品色哟哟在线观看| 高中生粉嫩无套第一次| 久久精品国产成人午夜福利| 国产中文字幕精品喷潮| 成av免费大片黄在线观看| 四虎永久在线高清免费看| 久久精品国产www456c0m| 国产伦精品一区二区三区|