Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- vector<vector<int>> a(9, vector<int> (9));
- for(int i=0; i<9; i++) for(int j=0; j<9; j++) cin>>a[i][j];
- int f = 1;
- set<int> st;
- for(int i=0; i<9; i++)
- {
- st.clear();
- for(int j=0; j<9; j++)
- st.insert(a[i][j]);
- f &= (st.size() == 9);
- st.clear();
- for(int j=0; j<9; j++)
- st.insert(a[j][i]);
- f &= (st.size() == 9);
- }
- for(int i=0; i<9; i+=3)
- {
- for(int j=0; j<9; j+=3)
- {
- st.clear();
- st.insert(a[i][j]);
- st.insert(a[i][j+1]);
- st.insert(a[i][j+2]);
- st.insert(a[i+1][j]);
- st.insert(a[i+1][j+1]);
- st.insert(a[i+1][j+2]);
- st.insert(a[i+2][j]);
- st.insert(a[i+2][j+1]);
- st.insert(a[i+2][j+2]);
- f &= (st.size() == 9);
- }
- }
- if(f) cout<<"Yes\n";
- else cout<<"No\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment