fork download
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int n;
	cin>>n;
	int ms[n][n]={};
	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			cin>>ms[i][j];
	vector<pair<int,int> >sr;
	for(int i=0; i<n; i++)
		for(int j=i+1; j<n; j++)
			if(ms[i][j]==1) sr.push_back({i,j});
	int m=sr.size();
	for(int i=0; i<m; i++)
		cout<<sr[i].first+1<<" "<<sr[i].second+1<<endl;
			
			
			
	return 0;
}
Success #stdin #stdout 0.01s 5296KB
stdin
5
0 0 1 0 0 
0 0 1 0 1 
1 1 0 0 0 
0 0 0 0 0 
0 1 0 0 0 
stdout
1 3
2 3
2 5