Submission #472354

#TimeUsernameProblemLanguageResultExecution timeMemory
472354Ahmed57Zamjena (COCI18_zamjena)C++14
70 / 70
169 ms15104 KiB
#include<bits/stdc++.h> using namespace std; map<string,vector<string>>adj; map<string,bool>vis; long long a=0; bool is(string s){ for(int i=0;i<s.size();i++){ if(s[i]<'0'||s[i]>'9') return false; } return true; } void dfs(string n){ if(is(n)) a++; vis[n]=true; for(auto i:adj[n]) if(!vis[i]) dfs(i); } int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL); int n; cin>>n; vector<string>arr(n); vector<string>aee(n); for(int i=0;i<n;i++){ cin>>arr[i]; } for(int i=0;i<n;i++){ cin>>aee[i]; adj[aee[i]].push_back(arr[i]); adj[arr[i]].push_back(aee[i]); } for(int i=0;i<n;i++){ a=0; if(is(arr[i])&&is(aee[i])){ if(arr[i]!=aee[i]){ cout<<"NE"<<endl; return 0; } } else{ if(is(arr[i])&&!vis[aee[i]])dfs(aee[i]); else if(is(aee[i])&&!vis[arr[i]])dfs(arr[i]); if(a>1){ cout<<"NE"<<endl; return 0; } } } cout<<"DA"<<endl; }

Compilation message (stderr)

zamjena.cpp: In function 'bool is(std::string)':
zamjena.cpp:8:18: 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++){
      |                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...