#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ldb,ldb> pdd;
#define ff(i,a,b) for(int i = a; i <= b; i++)
#define fb(i,b,a) for(int i = b; i >= a; i--)
#define trav(a,x) for(auto& a : x)
#define sz(a) (int)(a).size()
#define fi first
#define se second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// os.order_of_key(k) the number of elements in the os less than k
// *os.find_by_order(k) print the k-th smallest number in os(0-based)
const int mod = 1000000007;
const int inf = 1e9 + 5;
const int mxN = 2005;
int n;
int glv[mxN];
vector<int> A[mxN];
bool res[mxN];
bool bio[mxN];
vector<int> g[mxN];
bool P[mxN][mxN];
bool visited[mxN];
void dfs(int v, int r){
visited[v] = 1; P[r][v] = 1;
for(auto u : g[v]){
if(!visited[u]){
dfs(u, r);
}
}
}
int main(){
cin.tie(0)->sync_with_stdio(0);
cin >> n;
string s; getline(cin, s);
ff(i,1,n)res[i] = 1;
map<string,int> mp;
ff(i,1,n){
getline(cin, s);
int m = sz(s), last = 0; string ime = "";
ff(j,0,m - 1){
if(s[j] != ' ')continue;
ime = s.substr(last, j - last);
if(mp.count(ime)){
res[i] = 0;
break;
}
last = j + 1;
break;
}
if(res[i] == 0)continue;
ff(j,last,m - 1){
if(s[j] != ' ')continue;
string t = s.substr(last, j - last);
if(t != ":" && t != ";"){
if(!mp.count(t)){
res[i] = 0;
break;
}
A[i].pb(mp[t]);
}
last = j + 1;
}
if(res[i] == 0)continue;
mp[ime] = i;
}
ff(i,1,n){
cout << "i: " << i << '\n';
for(auto c : A[i])cout << c << " ";
cout << '\n';
}
ff(i,1,n){
if(res[i] == 0)continue;
cout << "i: " << i << '\n';
bool ok = 1;
for(auto a : A[i]){
for(auto b : A[i]){
if(a == b)continue;
if(!P[a][b] && !P[b][a]){
ff(c,1,n){
if(P[a][c] && P[b][c]){
ok = 0;
break;
}
}
}
if(ok == 0)break;
}
if(ok == 0)break;
}
if(ok == 0){
res[i] = 0;
continue;
}
for(auto c : A[i])g[i].pb(c);
ff(j,1,n)visited[j] = 0;
dfs(i, i);
res[i] = 1; bio[i] = 1;
}
ff(i,1,n)cout << (res[i] == 0 ? "greska" : "ok") << '\n';
return 0;
}
/*
// probati bojenje sahovski
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
453 ms |
12728 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |