답안 #464657

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464657 2021-08-13T15:21:33 Z Blobo2_Blobo2 Zamjena (COCI18_zamjena) C++14
70 / 70
101 ms 9080 KB
/*
Editor: Abdelrahman Hossam
Nickname: Blobo2_Blobo2
IOI next year isA :)
*/
/*#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define gen(arr,n,nxt)  generate(arr,arr+n,nxt)
#define Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty ios_base::sync_with_stdio(false);cin.tie(0);

const int mo=1e9+7,INF=1e18;
int nxt(){int x;cin>>x;return x;}
vector<int>adj[100001];
bool vis[100001];
signed main(){
    Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty
    int n=nxt();
    map<string,int>mp;
    int arr[n],brr[n];
    int idx=1;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s[0]>='0'&&s[0]<='9'){
            int num =0 ;
            for(int i=0;i<s.size();i++){
                num*=10;
                num+=s[i]-'0';
            }
            arr[i] = num;
        }
        else{
            if(!mp[s])mp[s] = idx+1000,idx++;
            arr[i] = mp[s];
        }
    }
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s[0]>='0'&&s[0]<='9'){
            int num =0 ;
            for(int i=0;i<s.size();i++){
                num*=10;
                num+=s[i]-'0';
            }
            brr[i] = num;
        }
        else{
            if(!mp[s])mp[s] = idx+1000,idx++;
            brr[i] = mp[s];
        }
    }
    for(int i=0;i<n;i++){
        adj[arr[i]].push_back(brr[i]);
        adj[brr[i]].push_back(arr[i]);
    }
    bool ok=0;
    for(int i=0;i<n;i++){
        if(!vis[arr[i]]){
            queue<int>q;
            vis[arr[i]]=1;
            q.push(arr[i]);
            int c=0;
            if(arr[i]<=1000)c++;
            while(!q.empty()){
                int u = q.front();q.pop();
                for(auto v:adj[u]){
                    if(!vis[v]){
                        if(v<=1000)c++;
                        vis[v] = 1;
                        q.push(v);
                    }
                }
            }
            if(c>1){
                ok=1;
                break;
            }
        }
    }
    cout<<(ok?"NE":"DA");
    return 0;
}

Compilation message

zamjena.cpp: In function 'int main()':
zamjena.cpp:34:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             for(int i=0;i<s.size();i++){
      |                         ~^~~~~~~~~
zamjena.cpp:50:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |             for(int i=0;i<s.size();i++){
      |                         ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2672 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2668 KB Output is correct
5 Correct 2 ms 2664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2764 KB Output is correct
2 Correct 3 ms 2636 KB Output is correct
3 Correct 5 ms 2940 KB Output is correct
4 Correct 5 ms 3020 KB Output is correct
5 Correct 5 ms 3020 KB Output is correct
6 Correct 5 ms 2892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 3660 KB Output is correct
2 Correct 30 ms 4828 KB Output is correct
3 Correct 49 ms 6256 KB Output is correct
4 Correct 56 ms 6856 KB Output is correct
5 Correct 101 ms 9080 KB Output is correct
6 Correct 67 ms 6856 KB Output is correct