Submission #723955

#TimeUsernameProblemLanguageResultExecution timeMemory
723955baneDijamant (COI16_dijament)C++17
100 / 100
182 ms4628 KiB
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <vector> #include <climits> #include <unordered_map> #include <unordered_set> #define pb push_back #define fr first #define sc second #define pq priority_queue #define all(x) begin(x), end(x) #define mp make_pair using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; const ll inf = (ll)1e18; const ll MOD = (ll)1e9 + 7; const int MAXN = 2000; void setPrec() { cout << fixed << setprecision(15); } void unsyncIO() { cin.tie(0)->sync_with_stdio(0); } void setIn(string s) { freopen(s.c_str(),"r",stdin); } void setOut(string s) { freopen(s.c_str(),"w",stdout); } void setIO(string s = "") { unsyncIO(); setPrec(); if ((int)s.size()) setIn(s+".in"), setOut(s+".out"); } int par[MAXN]; void solve(){ int N; cin >> N; map<string,int>vis; vector<int>a[N + 1]; for (int i = 1; i <= N; i++){ string s; cin >> s; char c; cin >> c; vector<int> v; bool bad = 0; while(1){ string t; cin >> t; if(t == ";")break; if(vis[t] == 0)bad = 1; v.push_back(vis[t]); } if (vis[s])bad = 1; // vis[k] = i; if (bad){ cout<<"greska"<<'\n'; continue; } for (int j = 0; j<=N; j++)par[j] = 0; function<void(int)>dfs = [&](int v){ for(auto u:a[v]){ if(bad)return; if(par[u]){ if(par[u] != v) bad = 1; } else{ par[u] = v; dfs(u); } } }; for (int p : v)dfs(p); if (!bad){ vis[s] = i; cout<<"ok"<<'\n'; for (auto p : v){ if (par[p] == 0){ //koren a[i].pb(p); } } }else{ cout<<"greska"<<'\n'; } } } int main(){ setIO(); solve(); return 0; }

Compilation message (stderr)

dijament.cpp: In function 'void setIn(std::string)':
dijament.cpp:37:31: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 | void setIn(string s) { freopen(s.c_str(),"r",stdin); }
      |                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
dijament.cpp: In function 'void setOut(std::string)':
dijament.cpp:38:32: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 | void setOut(string s) { freopen(s.c_str(),"w",stdout); }
      |                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...