Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lectricas/c5368c1f14f338163b67bdb36fa4fb45 to your computer and use it in GitHub Desktop.
Save lectricas/c5368c1f14f338163b67bdb36fa4fb45 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
using namespace std;
int main() {
int vertex_count;
cin >> vertex_count;
vector<vector<char>> matrix(vertex_count, vector<char>(vertex_count));
for (int i = 0; i < vertex_count; i++) {
for (int j = i + 1; j < vertex_count; j++) {
cin >> matrix[i][j];
}
}
int distance = 2;
while (distance < vertex_count) {
int start = 0;
int end = start + distance;
while (end < vertex_count) {
int middle = end - 1;
char result;
cout << start + 1 << " " << end + 1 << "\n";
if (matrix[start][middle] != matrix[middle][end]) {
result = 'U';
} else {
result = matrix[start][middle];
}
if (result != 'U') {
if (result != matrix[start][end]) {
cout << "NO";
return 0;
}
}
start = start + 1;
end = end + 1;
}
distance++;
}
cout << "YES";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment