Submission #1084188

#TimeUsernameProblemLanguageResultExecution timeMemory
1084188vjudge1KOVANICE (COI15_kovanice)C++17
0 / 100
760 ms40272 KiB
#include <bits/stdc++.h> using namespace std; int prv_broj(string s) { int x=0; for (int i=0;i<s.size();i++) { if (s[i]=='<' || s[i]=='=') return x; x = x*10 + (s[i]-'0'); } } bool znak(string s) { for (int i=0;i<s.size();i++) if (s[i]=='<') return true; else if (s[i]=='=') return false; } int vtor_broj(string s) { int p=0; while(s[p]!='<' && s[p]!='=') p++; p++; int y=0; while(p<s.size()) { y=y*10+(s[p]-'0'); p++; } return y; } int odg[300001]; bool visited[300001]; vector<vector<int> > v(1000000); void dfs(int p) { visited[p]=true; for (int i=0;i<v[p].size();i++) { int sosed = v[p][i]; if (visited[sosed]==false) { visited[sosed]=true; odg[sosed] = odg[p]; dfs(sosed); } } } int main() { int n,m,k; cin>>n>>m>>k; for (int i=0;i<k;i++) { string s; cin>>s; int x = prv_broj(s); bool z = znak(s); int y = vtor_broj(s); cout<<"epa "<<x <<" "<<z<<" "<<y<<endl; if (z) { odg[x]=1; odg[y]=2; } else{ v[x].push_back(y); v[y].push_back(x); } } for (int i=1;i<=m;i++) if (odg[i]>0 && visited[i]==false) dfs(i); for (int i=1;i<=m;i++) { if (odg[i]==0) cout<<"?\n"; else cout<<"K"<<odg[i]<<endl; } return 0; }

Compilation message (stderr)

kovanice.cpp: In function 'int prv_broj(std::string)':
kovanice.cpp:8:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for (int i=0;i<s.size();i++)
      |                  ~^~~~~~~~~
kovanice.cpp: In function 'bool znak(std::string)':
kovanice.cpp:17:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i=0;i<s.size();i++)
      |                  ~^~~~~~~~~
kovanice.cpp: In function 'int vtor_broj(std::string)':
kovanice.cpp:30:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     while(p<s.size())
      |           ~^~~~~~~~~
kovanice.cpp: In function 'void dfs(int)':
kovanice.cpp:45:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for (int i=0;i<v[p].size();i++)
      |                  ~^~~~~~~~~~~~
kovanice.cpp: In function 'int prv_broj(std::string)':
kovanice.cpp:13:1: warning: control reaches end of non-void function [-Wreturn-type]
   13 | }
      | ^
kovanice.cpp: In function 'bool znak(std::string)':
kovanice.cpp:20:1: warning: control reaches end of non-void function [-Wreturn-type]
   20 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...