Submission #99202

#TimeUsernameProblemLanguageResultExecution timeMemory
99202dsg213Dijamant (COI16_dijament)C++14
100 / 100
478 ms4744 KiB
#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)

dijament.cpp: In function 'int spr(int)':
dijament.cpp:30:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<kra[i].size();j++){
               ~^~~~~~~~~~~~~~
dijament.cpp: In function 'void rob(int)':
dijament.cpp:61:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<vs.size();i++){
              ~^~~~~~~~~~
dijament.cpp:78:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<use.size();i++){
              ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...