Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- typedef vector<int> Fila;
- typedef vector<Fila> Quadrat;
- bool es_llati(const Quadrat& q){
- Quadrat aux=q;
- int mida=q.size();
- for(int i=0;i<mida;++i){
- Fila fx(mida,0);
- for(int j=0;j<mida;++j) fx[j]=q[i][j];
- sort(fx.begin(),fx.end());
- for(int j=0;j<mida;++j){
- if(fx[j]!=j+1) return false;
- }
- }
- for(int i=0;i<mida;++i){
- Fila a(mida,0);
- for(int j=0;j<mida;++j){
- a[j]=aux[j][i];
- }
- sort(a.begin(),a.end());
- for(int j=0;j<mida;++j){
- if(a[j]!=j+1) return false;
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement