This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define sz(x) (int)x.size()
#define ff first
#define ss second
const ll N = 3005;
const ll M = 1e9 + 7;
int T, n, a[N][N];
map <string, int> m;
map <int,bool> vis;
int main(){
ios::sync_with_stdio(false); cin.tie(0);
cin >> n;
int cnt = 0;
for(int i = 1; i <= n; i++){
string s;
cin >> s;
if(m[s] == 0){
cnt++;
m[s] = cnt;
}
else {
string l1;
cin >> l1;
while(1){
cin >> l1;
if(l1 == ";") break;
}
cout << "greska\n";
continue;
}
string l;
cin >> l;
vector <int> v1;
bool tr = 0;
while(1){
cin >> l;
if(l == ";") break;
if(m[l] == 0) tr = 1;
v1.push_back(m[l]);
}
if(tr == 1){
m[s] = 0;
cnt--;
cout << "greska\n";
continue;
}
tr = 0;
for(int j = 1; j <= cnt; j++){
int cn = 0;
for(auto j1 : v1){
cn += a[j][j1];
}
if(cn >= 2){
tr = 1;
break;
}
}
if(tr == 1){
m[s] = 0;
cnt--;
cout << "greska\n";
continue;
}
for(auto j : v1){
if(j == m[s]) continue;
a[j][m[s]] = 1;
}
cout << "ok\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |