Submission #123639

#TimeUsernameProblemLanguageResultExecution timeMemory
123639samsDijamant (COI16_dijament)C++14
100 / 100
1996 ms8708 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3+10; int n, N; int nd, mk[maxn][maxn]; map<string, int> conv; int main() { cin >> n; N = n; while(N--) { string c, pt; cin >> c >> pt; set<string> II; vector<int> g; while(true) { string ss; cin >> ss; if(ss == ";") break; II.insert(ss); } if(conv.find(c) != conv.end()) { cout << "greska\n"; continue; } int ok = 0; conv[c] = ++nd; for(auto ii: II) { if(conv.find(ii) == conv.end()) { ok = 1; break; } g.push_back(conv[ii]); } if(ok) { conv.erase(c); nd--; cout << "greska\n"; continue; } for(int i = 0 ; i < g.size() ; ++i) { for(int j = i+1 ; j < g.size() ; ++j) { int a = g[i], b = g[j]; if(mk[a][b] == 1 || mk[b][a] == 1) continue; for(int k = 1 ; k < nd ; ++k) { if(mk[a][k] == 1 && mk[b][k] == 1) { ok = 1; break; } } } if(ok) break; } if(ok) { nd--; conv.erase(c); cout << "greska\n"; continue; } for(int u: g) { mk[nd][u] = 1; for(int i = 1 ; i < nd ; ++i) if(mk[u][i]) mk[nd][i] = 1; } cout << "ok\n"; /*for(int i = 1 ; i <= nd ;++i) { for(int j = 1 ; j <= nd ; ++j) { cout << mk[i][j] << " \n"[j == nd]; } }*/ } }

Compilation message (stderr)

dijament.cpp: In function 'int main()':
dijament.cpp:65:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0 ; i < g.size() ; ++i)
                   ~~^~~~~~~~~~
dijament.cpp:67:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j = i+1 ; j < g.size() ; ++j)
                      ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...