update
This commit is contained in:
		
							parent
							
								
									3b38ed3212
								
							
						
					
					
						commit
						cf2b7c528a
					
				@ -1,4 +1,5 @@
 | 
			
		||||
#include<bits/stdc++.h>
 | 
			
		||||
#include<iostream>
 | 
			
		||||
#include<map>
 | 
			
		||||
using namespace std;
 | 
			
		||||
typedef long long ll;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,5 @@
 | 
			
		||||
#include<bits/stdc++.h>
 | 
			
		||||
#include<iostream>
 | 
			
		||||
#include<sstream>
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
// bool is_pf(int n){
 | 
			
		||||
 | 
			
		||||
@ -1,98 +1,104 @@
 | 
			
		||||
#include<bits/stdc++.h>
 | 
			
		||||
using namespace std;
 | 
			
		||||
// #include<iostream>
 | 
			
		||||
// #include<optional>
 | 
			
		||||
// #include <utility>
 | 
			
		||||
// using namespace std;
 | 
			
		||||
 | 
			
		||||
int m[10][10];
 | 
			
		||||
bool h_is_used[10][10],l_is_used[10][10],t_is_used[5][5][10];
 | 
			
		||||
// int m[10][10];
 | 
			
		||||
// bool h_is_used[10][10],l_is_used[10][10],t_is_used[5][5][10];
 | 
			
		||||
 | 
			
		||||
#ifdef OI
 | 
			
		||||
#define DB(code){code}
 | 
			
		||||
#define PV(v){cout<<#v<<" : "<<(v)<<endl;}
 | 
			
		||||
#else
 | 
			
		||||
#define DB(code)
 | 
			
		||||
#define PV(v)
 | 
			
		||||
#endif
 | 
			
		||||
// #ifdef OI
 | 
			
		||||
// #define DB(code){code}
 | 
			
		||||
// #define PV(v){cout<<#v<<" : "<<(v)<<endl;}
 | 
			
		||||
// #else
 | 
			
		||||
// #define DB(code)
 | 
			
		||||
// #define PV(v)
 | 
			
		||||
// #endif
 | 
			
		||||
 | 
			
		||||
void dfs(int x,int y);
 | 
			
		||||
optional<pair<int,int>> find_next(int x,int y);
 | 
			
		||||
// void dfs(int x,int y);
 | 
			
		||||
// optional<pair<int,int>> find_next(int x,int y);
 | 
			
		||||
 | 
			
		||||
// int main(){
 | 
			
		||||
//     for(int i=1;i<=9;i++){
 | 
			
		||||
//         string str;
 | 
			
		||||
//         getline(cin,str);
 | 
			
		||||
//         for(int j=1;j<=9;j++){
 | 
			
		||||
//             if(str[j-1]=='.'){
 | 
			
		||||
//                 m[i][j]=-1;
 | 
			
		||||
//             }else{
 | 
			
		||||
//                 m[i][j]=str[j-1]-'0';
 | 
			
		||||
//                 h_is_used[i][m[i][j]]=true;
 | 
			
		||||
//                 l_is_used[j][m[i][j]]=true;
 | 
			
		||||
//                 t_is_used[i/3+1][j/3+1][m[i][j]]=true;
 | 
			
		||||
//             }
 | 
			
		||||
//         }
 | 
			
		||||
//     }
 | 
			
		||||
//     DB(
 | 
			
		||||
//         for(int i=1;i<=9;i++){
 | 
			
		||||
//             for(int j=1;j<=9;j++){
 | 
			
		||||
//                 cout<<m[i][j]<<"\t";
 | 
			
		||||
//             }
 | 
			
		||||
//             cout<<endl;
 | 
			
		||||
//         }
 | 
			
		||||
//     )
 | 
			
		||||
//     auto find = find_next(1, 1);
 | 
			
		||||
//     if(find.has_value()==false){
 | 
			
		||||
//         for(int i=1;i<=9;i++){
 | 
			
		||||
//             for(int j=1;j<=9;j++){
 | 
			
		||||
//                 cout<<m[i][j];
 | 
			
		||||
//             }
 | 
			
		||||
//             cout<<endl;
 | 
			
		||||
//         }
 | 
			
		||||
//         exit(0);
 | 
			
		||||
//     }
 | 
			
		||||
//     dfs(find->first, find->second);
 | 
			
		||||
// }
 | 
			
		||||
 | 
			
		||||
// optional<pair<int,int>> find_next(int x,int y){
 | 
			
		||||
//     for (int j=y+1; j<=9; j++) {
 | 
			
		||||
//         if(m[x][j]==-1){
 | 
			
		||||
//             return make_optional<pair<int,int>>({x,j});
 | 
			
		||||
//         }
 | 
			
		||||
//     }
 | 
			
		||||
//     for(int i=x+1;i<=9;i++){
 | 
			
		||||
//         for(int j=1;j<=9;j++){
 | 
			
		||||
//             if(m[i][j]==-1){
 | 
			
		||||
//                 return make_optional<pair<int,int>>({i,j});
 | 
			
		||||
//             }
 | 
			
		||||
//         }
 | 
			
		||||
//     }
 | 
			
		||||
//     return nullopt;
 | 
			
		||||
// }   
 | 
			
		||||
 | 
			
		||||
// void dfs(int x,int y){
 | 
			
		||||
//     DB(PV(x)PV(y)cout<<endl;)
 | 
			
		||||
//     auto find = find_next(x, y);
 | 
			
		||||
//     if(find.has_value()==false){
 | 
			
		||||
//         for(int i=1;i<=9;i++){
 | 
			
		||||
//             for(int j=1;j<=9;j++){
 | 
			
		||||
//                 cout<<m[i][j];
 | 
			
		||||
//             }
 | 
			
		||||
//             cout<<endl;
 | 
			
		||||
//         }
 | 
			
		||||
//         exit(0);
 | 
			
		||||
//     }
 | 
			
		||||
//     for(int i=1;i<=9;i++){
 | 
			
		||||
//         if(h_is_used[x][i]||l_is_used[y][i]||t_is_used[x/3+1][y/3+1][i]){
 | 
			
		||||
//             continue;
 | 
			
		||||
//         }
 | 
			
		||||
//         h_is_used[x][i]=true,
 | 
			
		||||
//         l_is_used[y][i]=true,
 | 
			
		||||
//         t_is_used[x/3+1][y/3+1][i]=true;
 | 
			
		||||
//         m[x][y]=i;
 | 
			
		||||
 | 
			
		||||
//         dfs(find->first, find->second);
 | 
			
		||||
 | 
			
		||||
//         h_is_used[x][i]=false;
 | 
			
		||||
//         l_is_used[y][i]=false;
 | 
			
		||||
//         t_is_used[x/3+1][y/3+1][i]=false;
 | 
			
		||||
//         m[x][y]=-1;
 | 
			
		||||
//     }
 | 
			
		||||
// }
 | 
			
		||||
 | 
			
		||||
int main(){
 | 
			
		||||
    for(int i=1;i<=9;i++){
 | 
			
		||||
        string str;
 | 
			
		||||
        getline(cin,str);
 | 
			
		||||
        for(int j=1;j<=9;j++){
 | 
			
		||||
            if(str[j-1]=='.'){
 | 
			
		||||
                m[i][j]=-1;
 | 
			
		||||
            }else{
 | 
			
		||||
                m[i][j]=str[j-1]-'0';
 | 
			
		||||
                h_is_used[i][m[i][j]]=true;
 | 
			
		||||
                l_is_used[j][m[i][j]]=true;
 | 
			
		||||
                t_is_used[i/3+1][j/3+1][m[i][j]]=true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    DB(
 | 
			
		||||
        for(int i=1;i<=9;i++){
 | 
			
		||||
            for(int j=1;j<=9;j++){
 | 
			
		||||
                cout<<m[i][j]<<"\t";
 | 
			
		||||
            }
 | 
			
		||||
            cout<<endl;
 | 
			
		||||
        }
 | 
			
		||||
    )
 | 
			
		||||
    auto find = find_next(1, 1);
 | 
			
		||||
    if(find.has_value()==false){
 | 
			
		||||
        for(int i=1;i<=9;i++){
 | 
			
		||||
            for(int j=1;j<=9;j++){
 | 
			
		||||
                cout<<m[i][j];
 | 
			
		||||
            }
 | 
			
		||||
            cout<<endl;
 | 
			
		||||
        }
 | 
			
		||||
        exit(0);
 | 
			
		||||
    }
 | 
			
		||||
    dfs(find->first, find->second);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
optional<pair<int,int>> find_next(int x,int y){
 | 
			
		||||
    for (int j=y+1; j<=9; j++) {
 | 
			
		||||
        if(m[x][j]==-1){
 | 
			
		||||
            return make_optional<pair<int,int>>({x,j});
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    for(int i=x+1;i<=9;i++){
 | 
			
		||||
        for(int j=1;j<=9;j++){
 | 
			
		||||
            if(m[i][j]==-1){
 | 
			
		||||
                return make_optional<pair<int,int>>({i,j});
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return nullopt;
 | 
			
		||||
}   
 | 
			
		||||
 | 
			
		||||
void dfs(int x,int y){
 | 
			
		||||
    DB(PV(x)PV(y)cout<<endl;)
 | 
			
		||||
    auto find = find_next(x, y);
 | 
			
		||||
    if(find.has_value()==false){
 | 
			
		||||
        for(int i=1;i<=9;i++){
 | 
			
		||||
            for(int j=1;j<=9;j++){
 | 
			
		||||
                cout<<m[i][j];
 | 
			
		||||
            }
 | 
			
		||||
            cout<<endl;
 | 
			
		||||
        }
 | 
			
		||||
        exit(0);
 | 
			
		||||
    }
 | 
			
		||||
    for(int i=1;i<=9;i++){
 | 
			
		||||
        if(h_is_used[x][i]||l_is_used[y][i]||t_is_used[x/3+1][y/3+1][i]){
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
        h_is_used[x][i]=true,
 | 
			
		||||
        l_is_used[y][i]=true,
 | 
			
		||||
        t_is_used[x/3+1][y/3+1][i]=true;
 | 
			
		||||
        m[x][y]=i;
 | 
			
		||||
 | 
			
		||||
        dfs(find->first, find->second);
 | 
			
		||||
 | 
			
		||||
        h_is_used[x][i]=false;
 | 
			
		||||
        l_is_used[y][i]=false;
 | 
			
		||||
        t_is_used[x/3+1][y/3+1][i]=false;
 | 
			
		||||
        m[x][y]=-1;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
#include<bits/stdc++.h>
 | 
			
		||||
#include<iostream>
 | 
			
		||||
using namespace std;
 | 
			
		||||
typedef long long ll;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,4 @@
 | 
			
		||||
#include <cmath>
 | 
			
		||||
#include <cstdio>
 | 
			
		||||
#include<iostream>
 | 
			
		||||
#include <numeric>
 | 
			
		||||
#include <sstream>
 | 
			
		||||
@ -17,16 +16,16 @@ std::ostream& operator<<(std::ostream &os,const std::vector<int> &v){
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<typename ...Args>
 | 
			
		||||
void print(const Args& ...args){
 | 
			
		||||
void zprint(const Args& ...args){
 | 
			
		||||
    ((std::cout<<args),...);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<typename ...Args>
 | 
			
		||||
void println(const Args& ...args){
 | 
			
		||||
void zprintln(const Args& ...args){
 | 
			
		||||
    std::stringstream ss;
 | 
			
		||||
    ((ss<<args<<" "),...);
 | 
			
		||||
    ss<<"\n";
 | 
			
		||||
    print(ss.str());
 | 
			
		||||
    zprint(ss.str());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define NAME_VALUE(v)#v,":",(v)
 | 
			
		||||
@ -34,21 +33,21 @@ void println(const Args& ...args){
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int main(){
 | 
			
		||||
    println("Hello,World!","-by","Zengtudor");
 | 
			
		||||
    println("End");
 | 
			
		||||
    println(NAME_VALUE(std::pow(2,10)));
 | 
			
		||||
    println(NAME_VALUE((int)0x7FFFFFFF));
 | 
			
		||||
    zprintln("Hello,World!","-by","Zengtudor");
 | 
			
		||||
    zprintln("End");
 | 
			
		||||
    zprintln(NAME_VALUE(std::pow(2,10)));
 | 
			
		||||
    zprintln(NAME_VALUE((int)0x7FFFFFFF));
 | 
			
		||||
    std::vector<int> v(10);
 | 
			
		||||
    v[0]=1;
 | 
			
		||||
    for(int i=1;(u8)i<v.size();i++){
 | 
			
		||||
        v[i]=(v[i-1]*3+2)%49;
 | 
			
		||||
    }
 | 
			
		||||
    println(NAME_VALUE(v));
 | 
			
		||||
    println(NAME_VALUE(std::pow(3, 8)));
 | 
			
		||||
    println(NAME_VALUE(std::gcd(41184, 65208)));
 | 
			
		||||
    zprintln(NAME_VALUE(v));
 | 
			
		||||
    zprintln(NAME_VALUE(std::pow(3, 8)));
 | 
			
		||||
    zprintln(NAME_VALUE(std::gcd(41184, 65208)));
 | 
			
		||||
 | 
			
		||||
    for(int i=1;i<=1e4;i++){
 | 
			
		||||
        print(i,",");
 | 
			
		||||
        zprint(i,",");
 | 
			
		||||
    }
 | 
			
		||||
    print("\n");
 | 
			
		||||
    zprint("\n");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user