Submission #779069

# Submission time Handle Problem Language Result Execution time Memory
779069 2023-07-11T07:20:08 Z vjudge1 Zamjena (COCI18_zamjena) C++17
70 / 70
92 ms 9868 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
#define OYY 1000000005
#define mod 998244353
map <string,int> mp;
bool vis[50005];
int tut=0;
vector <int> v;
vector <int> vt[50005];

inline void dfs(int node){
    vis[node]=1;
    for(int i=0;i<vt[node].size();i++){
        if(!vis[vt[node][i]])dfs(vt[node][i]);
    }
}

int32_t main(){
    faster
    memset(vis,0,sizeof(vis));
    int n;cin>>n;
    string dizi[n],dizi1[n];
    for(int i=0;i<n;i++){
        cin>>dizi[i];
        if(!mp.count(dizi[i])){
            mp[dizi[i]]=tut;
            tut++;
        }
    }
    for(int i=0;i<n;i++){
        cin>>dizi1[i];
        if(!mp.count(dizi1[i])){
            mp[dizi1[i]]=tut;
            tut++;
        }
    }
    for(int i=0;i<n;i++){
        vt[mp[dizi[i]]].push_back(mp[dizi1[i]]);
        vt[mp[dizi1[i]]].push_back(mp[dizi[i]]);
    }
    map<string,int> ::iterator it=mp.begin();
    while(it!=mp.end()){
        string  su=it->first;
        if(su[0]>='0' && su[0]<='9'){
            v.push_back(it->second);
        }
        it++;
    }
    bool stop=true;
    for(int i=0;i<v.size() && stop;i++){
        if(!vis[v[i]])dfs(v[i]);
        else stop=false;
    }
    if(stop)cout<<"DA"<<'\n';
    else cout<<"NE"<<'\n';
    return 0;
}

Compilation message

zamjena.cpp: In function 'void dfs(long long int)':
zamjena.cpp:15:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i=0;i<vt[node].size();i++){
      |                 ~^~~~~~~~~~~~~~~~
zamjena.cpp: In function 'int32_t main()':
zamjena.cpp:52:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(int i=0;i<v.size() && stop;i++){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 1 ms 1492 KB Output is correct
4 Correct 1 ms 1492 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 1 ms 1492 KB Output is correct
4 Correct 1 ms 1492 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 2 ms 1492 KB Output is correct
3 Correct 1 ms 1492 KB Output is correct
4 Correct 1 ms 1492 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1620 KB Output is correct
2 Correct 2 ms 1620 KB Output is correct
3 Correct 4 ms 2004 KB Output is correct
4 Correct 6 ms 2020 KB Output is correct
5 Correct 5 ms 2008 KB Output is correct
6 Correct 4 ms 1980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2900 KB Output is correct
2 Correct 27 ms 4548 KB Output is correct
3 Correct 47 ms 6196 KB Output is correct
4 Correct 62 ms 7392 KB Output is correct
5 Correct 92 ms 9868 KB Output is correct
6 Correct 72 ms 7752 KB Output is correct