Created
May 10, 2021 11:16
-
-
Save lectricas/c5368c1f14f338163b67bdb36fa4fb45 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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