Skip to content

Commit

Permalink
add PARADOX
Browse files Browse the repository at this point in the history
  • Loading branch information
t3nsor committed Apr 29, 2016
1 parent 870ae3b commit f07542c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions paradox.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 2016-04-28
#include <cstdio>
#include <vector>
using namespace std;
int main() {
int N;
for (;;) {
scanf("%d", &N);
if (!N) return 0;
vector<vector<char>> adj(2*N, vector<char>(2*N));
for (int i = 0; i < N; i++) {
int j; char s[10];
scanf("%d %s", &j, s); j--;
if (s[0] == 't') {
adj[i][j] = true; adj[j+N][i+N] = true;
adj[i+N][j+N] = true; adj[j][i] = true;
} else {
adj[i][j+N] = true; adj[j][i+N] = true;
adj[i+N][j] = true; adj[j+N][i] = true;
}
}
for (int k = 0; k < 2*N; k++) {
for (int i = 0; i < 2*N; i++) {
for (int j = 0; j < 2*N; j++) {
adj[i][j] |= adj[i][k] && adj[k][j];
}
}
}
bool paradox = false;
for (int i = 0; i < N; i++) {
paradox |= adj[i][i+N];
}
if (paradox) {
puts("PARADOX");
} else {
puts("NOT PARADOX");
}
}
}

0 comments on commit f07542c

Please sign in to comment.