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;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt")
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
#define _all(T) T.begin(),T.end()
const int mxn = 1010;
vector<int> paths[mxn];
vector<string> in[mxn];
bitset<mxn> active;
int cnt[mxn];
bitset<mxn> up[mxn];
int n;
map<string,int> mp;
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
while(n--){
string tmp;
string now;
cin>>now;
vector<int> v;
cin>>tmp;
bool flag = true;
while(cin>>tmp){
if(tmp == ";")break;
if(mp.find(tmp) == mp.end()){
flag = false;
continue;
}
v.push_back(mp[tmp]);
}
if(mp.find(now) != mp.end())flag = false;
if(!flag){
cout<<"greska\n";
continue;
}
sort(v.rbegin(),v.rend());
bitset<mxn> dp;
dp.reset();
if(!v.empty())dp = up[v[0]];
for(int i = 1;i<v.size();i++){
if(dp[v[i]])continue;
else if((dp&up[v[i]]).any())flag = false;
dp|=up[v[i]];
}
if(!flag){
cout<<"greska\n";
continue;
}
mp[now] = mp.size()+1;
int tid = mp[now];
up[tid][tid] = true;
for(auto &i:v)up[tid]|=up[i];
cnt[tid] = up[tid].count();
cout<<"ok\n";
}
return 0;
}
Compilation message (stderr)
dijament.cpp: In function 'int main()':
dijament.cpp:52:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for(int i = 1;i<v.size();i++){
| ~^~~~~~~~~
# | 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... |