Submission #472354

# Submission time Handle Problem Language Result Execution time Memory
472354 2021-09-13T12:09:01 Z Ahmed57 Zamjena (COCI18_zamjena) C++14
70 / 70
169 ms 15104 KB
#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

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 time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 588 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 4 ms 972 KB Output is correct
4 Correct 3 ms 972 KB Output is correct
5 Correct 6 ms 1148 KB Output is correct
6 Correct 4 ms 1040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 3208 KB Output is correct
2 Correct 60 ms 5700 KB Output is correct
3 Correct 60 ms 7776 KB Output is correct
4 Correct 67 ms 9484 KB Output is correct
5 Correct 169 ms 15104 KB Output is correct
6 Correct 96 ms 11588 KB Output is correct