From b651b711343675f4e4896e1130350246b89dc4f7 Mon Sep 17 00:00:00 2001 From: ShazidMahsrafi Date: Sun, 10 Dec 2023 02:19:35 +0600 Subject: [PATCH] updated logic of 1904A --- 1904A Forked!/1904A.cpp | 42 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/1904A Forked!/1904A.cpp b/1904A Forked!/1904A.cpp index f974fbd..8d745b9 100644 --- a/1904A Forked!/1904A.cpp +++ b/1904A Forked!/1904A.cpp @@ -80,39 +80,19 @@ void solve() int a,b,k1,k2,q1,q2; cin>>a>>b>>k1>>k2>>q1>>q2; set > k,q; - k.ins({k1+a,k2+b}); - k.ins({k1+a,k2-b}); - - k.ins({k1+b,k2+a}); - k.ins({k1-b,k2+a}); - - k.ins({k1-a,k2+b}); - k.ins({k1-a,k2-b}); - - k.ins({k1+b,k2-a}); - k.ins({k1-b,k2-a}); - - q.ins({q1+a,q2+b}); - q.ins({q1+a,q2-b}); - - q.ins({q1+b,q2+a}); - q.ins({q1-b,q2+a}); - - q.ins({q1-a,q2+b}); - q.ins({q1-a,q2-b}); - - q.ins({q1+b,q2-a}); - q.ins({q1-b,q2-a}); + int x[4]={-1,1,-1,1}, y[4]={-1,-1,1,1}; + for(int i=0; i<4; ++i) + { + k.insert({k1+a*x[i],k2+b*y[i]}); + k.insert({k1+b*x[i],k2+a*y[i]}); + q.insert({q1+a*x[i],q2+b*y[i]}); + q.insert({q1+b*x[i],q2+a*y[i]}); + } int ct=0; - for(auto x:k) - { - for(auto y:q) - { - if(x==y) - ct++; - } - } + for(auto it:k) + if(q.find(it)!=q.end()) + ct++; cout<