Submission #1019460

#TimeUsernameProblemLanguageResultExecution timeMemory
1019460stefanopulosDijamant (COI16_dijament)C++17
27 / 100
405 ms10324 KiB
#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]; 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){ if(res[i] == 0)continue; for(auto c : A[i])g[i].pb(c); ff(j,1,n)visited[j] = 0; dfs(i, i); bool ok = 1; ff(a,1,i - 1){ ff(b,a + 1,i - 1){ if(!P[i][a] || !P[i][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){ res[i] = 0; for(auto c : A[i])g[i].pop_back(); ff(j,1,n)P[i][j] = 0; continue; } res[i] = 1; } ff(i,1,n)cout << (res[i] == 0 ? "greska" : "ok") << '\n'; return 0; } /* // probati bojenje sahovski */

Compilation message (stderr)

dijament.cpp: In function 'int main()':
dijament.cpp:138:22: warning: unused variable 'c' [-Wunused-variable]
  138 |             for(auto c : A[i])g[i].pop_back();
      |                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...