# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
99202 | dsg213 | Dijamant (COI16_dijament) | C++14 | 478 ms | 4744 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define ll long long
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
const int mod=1000000007,mxn=1010;
vector<int> kra[mxn];
int zal[mxn];
map<string,int> mapp;
int dp[mxn];
int dod[mxn];
vector<int> use;
int spr(int kt){
use.clear();
for(int i=kt-1;i>0;i--){
if(dod[i]==1 && dp[i]==0){
use.pb(i);
dp[i]=1;
}
if(!dp[i]){
continue;
}
for(int j=0;j<kra[i].size();j++){
dp[kra[i][j]]++;
if(dp[kra[i][j]]==2){
return 0;
}
}
}
return 1;
}
void rob(int kt){
string s;
cin >>s;
string s2;
cin >>s2;
vector<string> vs;
while(1){
cin >>s2;
if(s2==";"){
break;
}
vs.pb(s2);
}
if(mapp[s]){
cout <<"greska\n";
return;
}
vector<int> vec;
for(int i=0;i<=kt;i++){
dp[i]=0;
dod[i]=0;
}
for(int i=0;i<vs.size();i++){
if(!mapp[vs[i]]){
cout <<"greska\n";
return;
}
vec.pb(mapp[vs[i]]);
//cout <<vec[i] <<" ";
dod[vec[i]]=1;
}
int x=spr(kt);
if(x==0){
cout <<"greska\n";
return;
}
mapp[s]=kt;
cout <<"ok\n";
//cout <<"po " <<vs.size() <<endl;
for(int i=0;i<use.size();i++){
kra[kt].pb(use[i]);
}
}
int main(){
//ios_base::sync_with_stdio(0);
//cin.tie(0);
int n;
cin >>n;
for(int i=1;i<=n;i++){
rob(i);
/*for(int j=1;j<=i;j++){
cout <<j <<": ";
for(int x=0;x<kra[j].size();x++){
cout <<kra[j][x]<<" ";
}
cout <<"\n";
}*/
}
}
Compilation message (stderr)
# | 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... |