Submission #464657

#TimeUsernameProblemLanguageResultExecution timeMemory
464657Blobo2_Blobo2Zamjena (COCI18_zamjena)C++14
70 / 70
101 ms9080 KiB
/* 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 (stderr)

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++){
      |                         ~^~~~~~~~~
#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...