Submission #150262

#TimeUsernameProblemLanguageResultExecution timeMemory
150262PedroBigManZamjena (COCI18_zamjena)C++14
56 / 70
1058 ms1064 KiB
#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <string> using namespace std; typedef long long int ll; typedef unsigned long long int ull; typedef long double ld; #define REP(i,a,b) for(ll i=a; i<b; i++) #define pb push_back #define mp make_pair #define pl pair<ll,ll> #define ff first #define ss second #define INF ((ll) pow(2,63) -1) ll insig; #define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);} void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;} bool E(string a, string b) { if(a.size()!=b.size()) {return false;} REP(i,0,a.size()) {if(a[i]!=b[i]) {return false;}} return true; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll N; cin>>N; vector<string> var; vector<pl> a; vector<pl> b; string s; bool isint; ll cur; REP(i,0,N) { cin>>s; isint=true; cur=0; REP(j,0,s.size()) { if((((ll) s[j]) < 48) || (((ll) s[j]) > 57)) {isint=false;} cur+=(pow(10,s.size()-j-1))*(((ll) s[j]) - 48); } if(isint) {a.pb(mp(1,cur));} else { bool found=false; REP(j,0,var.size()) { if(E(s,var[j])) { found = true; a.pb(mp(0,j)); } } if(!found) {var.pb(s); a.pb(mp(0,var.size()-1));} } } REP(i,0,N) { cin>>s; isint=true; cur=0; REP(j,0,s.size()) { if((((ll) s[j]) < 48) || (((ll) s[j]) > 57)) {isint=false;} cur+=(pow(10,s.size()-j-1))*(((ll) s[j]) - 48); } if(isint) {b.pb(mp(1,cur));} else { bool found=false; REP(j,0,var.size()) { if(E(s,var[j])) { found = true; b.pb(mp(0,j)); } } if(!found) {var.pb(s); b.pb(mp(0,var.size()-1));} } } ll ind,val,ind1,ind2; REP(i,0,N) { if(a[i].ff==0 && b[i].ff==0) { ind1=a[i].ss; ind2=b[i].ss; REP(j,0,N) { if(a[j].ff==0 && a[j].ss==ind1) {a[j].ff=0; a[j].ss=ind2;} if(b[j].ff==0 && b[j].ss==ind1) {b[j].ff=0; b[j].ss=ind2;} } } else if(a[i].ff==0 && b[i].ff==1) { ind = a[i].ss; val=b[i].ss; REP(j,0,N) { if(a[j].ff==0 && a[j].ss==ind) {a[j].ff=1; a[j].ss=val;} if(b[j].ff==0 && b[j].ss==ind) {b[j].ff=1; b[j].ss=val;} } } else if(a[i].ff==1 && b[i].ff==0) { ind = b[i].ss; val=a[i].ss; REP(j,0,N) { if(a[j].ff==0 && a[j].ss==ind) {a[j].ff=1; a[j].ss=val;} if(b[j].ff==0 && b[j].ss==ind) {b[j].ff=1; b[j].ss=val;} } } else if(a[i].ff==1 && b[i].ff==1) { if(a[i].ss!=b[i].ss) {cout<<"NE"<<endl; return 0;} } } cout<<"DA"<<endl; return 0; }

Compilation message (stderr)

zamjena.cpp: In function 'void Out(std::vector<long long int>)':
zamjena.cpp:10:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
zamjena.cpp:19:29:
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                             ~~~~~~~~~~~~
zamjena.cpp:19:25: note: in expansion of macro 'REP'
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                         ^~~
zamjena.cpp: In function 'bool E(std::__cxx11::string, std::__cxx11::string)':
zamjena.cpp:10:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
zamjena.cpp:24:9:
     REP(i,0,a.size()) {if(a[i]!=b[i]) {return false;}}
         ~~~~~~~~~~~~             
zamjena.cpp:24:5: note: in expansion of macro 'REP'
     REP(i,0,a.size()) {if(a[i]!=b[i]) {return false;}}
     ^~~
zamjena.cpp: In function 'int main()':
zamjena.cpp:10:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
zamjena.cpp:38:13:
         REP(j,0,s.size()) 
             ~~~~~~~~~~~~         
zamjena.cpp:38:9: note: in expansion of macro 'REP'
         REP(j,0,s.size()) 
         ^~~
zamjena.cpp:10:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
zamjena.cpp:47:17:
             REP(j,0,var.size())
                 ~~~~~~~~~~~~~~   
zamjena.cpp:47:13: note: in expansion of macro 'REP'
             REP(j,0,var.size())
             ^~~
zamjena.cpp:10:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
zamjena.cpp:63:13:
         REP(j,0,s.size()) 
             ~~~~~~~~~~~~         
zamjena.cpp:63:9: note: in expansion of macro 'REP'
         REP(j,0,s.size()) 
         ^~~
zamjena.cpp:10:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
zamjena.cpp:72:17:
             REP(j,0,var.size())
                 ~~~~~~~~~~~~~~   
zamjena.cpp:72:13: note: in expansion of macro 'REP'
             REP(j,0,var.size())
             ^~~
#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...