1.0000111000101100001011000000111
00010110000100001000011100010110
10001100100001110001011010001110
00001010000001110001011000010110
00000111000101100001000010000111
00010110100011001000011100001101
10010110000010100000011100010110
00001101100001110001011000010111
00000111000101100001000100000111
00010110000101101000011100010110
10010101100010100000011100010110
00010110100001110001011000001110
2.0000111000101100001000010000111
00010110000100000000101000000111
10001101000001110001011000010101
00000111000101101000110010000111
00010110100101011000101000000111
00010110000011011000011100010110
00010111000001110001011000010000
00000111000101100000111000000111
00010110000101110000011100010110
10001100100001110001011000010000
10000111000101101000110110000111
00010110100011010000011100010110
10010111100010100000011100010110
00010111100001110001011000010101
10000111000101100000110010000111
00010110000101100000011100010110
100101111
00000111000101100001011010000111
00010110100011100000011100010110
00001111100001110001011000010110
1000011100010110000101110
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
int n;
cin >> n;
vector<vector<int>> a(n, vector<int> (n));
vector<int> x(2*n);
map<int,int> m;
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
cin >> a[i][j];
int cur1 = 1, cur2 = 0, elem = 0, cnt = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(i == j){
x[cur1] = a[i][j];
cur1 += 2;
m[a[i][j]]++;
if(m[a[i][j]] > cnt){
cnt = m[a[i][j]];
elem = a[i][j];
}
if(i + j == n - 1){
x[cur2] = a[i][j];
cur2 += 2;
for(auto &i : x) cout << i << " ";
cout << "\nThe most popular element is : " << elem;
1.0000111000101100001011000000111
00010110000100001000011100010110
10001100100001110001011010001110
00001010000001110001011000010110
00000111000101100001000010000111
00010110100011001000011100001101
10010110000010100000011100010110
00001101100001110001011000010111
00000111000101100001000100000111
00010110000101101000011100010110
10010101100010100000011100010110
00010110100001110001011000001110
2.0000111000101100001000010000111
00010110000100000000101000000111
00010110000100001000011100010110
10001101000001110001011000010101
00000111000101101000110010000111
00010110100101011000101000000111
00010110000011011000011100010110
00010111000001110001011000010000
00000111000101100000111000000111
00010110000101110000011100010110
10001100100001110001011000010000
10000111000101101000110110000111
00010110100011010000011100010110
10010111100010100000011100010110
00010111100001110001011000010101
10000111000101100000110010000111
00010110000101100000011100010110
100101111
00000111000101100001011010000111
00010110100011100000011100010110
00001111100001110001011000010110
1000011100010110000101110
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
int n;
cin >> n;
vector<vector<int>> a(n, vector<int> (n));
vector<int> x(2*n);
map<int,int> m;
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
cin >> a[i][j];
int cur1 = 1, cur2 = 0, elem = 0, cnt = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(i == j){
x[cur1] = a[i][j];
cur1 += 2;
m[a[i][j]]++;
if(m[a[i][j]] > cnt){
cnt = m[a[i][j]];
elem = a[i][j];
}
}
if(i + j == n - 1){
x[cur2] = a[i][j];
cur2 += 2;
m[a[i][j]]++;
if(m[a[i][j]] > cnt){
cnt = m[a[i][j]];
elem = a[i][j];
}
}
}
}
for(auto &i : x) cout << i << " ";
cout << "\nThe most popular element is : " << elem;
}