|
|
вернуться в форумGetting WA#2 ll n; ll ar[300][300]; int main(){ cin >> n; for(ll i = 1; i <= n; i ++) for(ll j = 1; j <= n; j ++) ar[i][j] = 0; for(ll i = 1; i <= n; i ++){ while(1){ ll x; cin >> x; if(x == -1) break; ar[x][i] = 1; } } for(ll i = 1; i <= n; i ++) ar[i][n+1] = 1; ll col = 1; while(col <= n){ if(ar[col][col] == 1){ for(ll i = 1; i <= n; i ++){ if(i == col) continue; if(ar[i][col] == 1){ //choose ith row for(ll j = 1; j <= n+1; j ++) ar[i][j] = ar[i][j]^ar[col][j]; } } } else{ break; } col ++; } bool f = 1; ll br[300][300]; for(ll i = 1; i <= n; i ++) for(ll j = 1; j <= n; j ++) if(i==j) br[i][j] = 1; for(ll i = 1; i <= n; i ++){ for(ll j = 1; j <= n; j ++) if(ar[i][j]!=br[i][j]) f = 0; } if(!f) cout << "No solution" << endl; else{ for(ll i = 1; i <= n; i ++){ if(ar[i][n+1]==1) cout << i << " "; } } return 0; } I have used basic Gauss algorithm making the augmented matrix equal to an identity matrix. Still getting WA. Please help Thank you :) Edited by author 04.12.2016 10:11 |
|
|