Submission #464620

#TimeUsernameProblemLanguageResultExecution timeMemory
464620aihayZamjena (COCI18_zamjena)C++14
28 / 70
24 ms32336 KiB
#pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize("-Ofast") #include <bits/stdc++.h> using namespace std; typedef int in; #define int long long #define f first #define s second #define pb push_back #define pp push #define double long double #define ceil(x,y) (x/y)+(x%y!=0)*((double)(1.0*x/y)<0?0:1) #define floor(x,y) (x/y)+(x%y!=0)*((double)(1.0a*x/y)<0?-1:0) const int MAX=1e7; const int MOD=1e9+7; const int MAAX=1e18; int arr[500010],arr2[500010]; string s[500010],s2[500010]; map<string,int> mp; in main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int tc=1; //cin>>tc; while(tc--){ int n; cin>>n; for(int i=0;i<n;i++){ cin>>s[i]; if(s[i][0]>='0'&&s[i][0]<='9'){ for(int j=0;j<s[i].size();j++){ arr[i]*=10; arr[i]+=s[i][j]-'0'; } s[i]=""; } else{ arr[i]=-1; } } for(int i=0;i<n;i++){ cin>>s2[i]; if(s2[i][0]>='0'&&s2[i][0]<='9'){ for(int j=0;j<s2[i].size();j++){ arr2[i]*=10; arr2[i]+=s2[i][j]-'0'; } s2[i]=""; } else{ arr2[i]=-1; } if(~arr2[i]&&~arr[i]) continue; if(~arr[i]){ arr2[i]=arr[i]; mp[s2[i]]=arr[i]; continue; } if(~arr2[i]){ arr[i]=arr2[i]; mp[s[i]]=arr[i]; continue; } } for(int i=0;i<n;i++){ if(arr2[i]==-1&&arr[i]==-1){ if(mp[s[i]]&&mp[s2[i]]==0){ mp[s2[i]]=mp[s[i]]; } else if(mp[s2[i]]&&mp[s[i]]==0) mp[s[i]]=mp[s2[i]]; else if(mp[s[i]]==0) mp[s[i]]=mp[s2[i]]=1; arr[i]=mp[s[i]]; arr2[i]=mp[s2[i]]; } if(arr[i]!=arr2[i]||arr[i]==-1||arr2[i]==-1){ cout<<"NE\n"; return 0; } } cout<<"DA\n"; } }

Compilation message (stderr)

zamjena.cpp: In function 'in main()':
zamjena.cpp:34:30: 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 j=0;j<s[i].size();j++){
      |                             ~^~~~~~~~~~~~
zamjena.cpp:47:30: 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]
   47 |                 for(int j=0;j<s2[i].size();j++){
      |                             ~^~~~~~~~~~~~~
#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...