From f0f6c31ea0a6b7cd11ad21b7422d35e79d886be0 Mon Sep 17 00:00:00 2001 From: RAJ VARDHAN <81090051+rajethanm4@users.noreply.github.com> Date: Sun, 3 Oct 2021 00:28:50 +0530 Subject: [PATCH 1/4] Create building.cpp --- building.cpp | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 building.cpp diff --git a/building.cpp b/building.cpp new file mode 100644 index 0000000..3a102df --- /dev/null +++ b/building.cpp @@ -0,0 +1,83 @@ +#include +#define IOS \ + ios::sync_with_stdio(0); \ + cin.tie(0); \ + cout.tie(0); +#define endl "\n" +#define ll long long int +#define pb push_back +#define ma make_pair +#define f1(i, a, b) for (int i = a; i < b; i++) +#define f2(i, a, b) for (int i = a; i > b; i--) +#define ff first +#define ss second +#define lb lower_bound +#define ub upper_bound +#define mod 1000000007 +#define ii pair +#define vi vector +#define vl vector +#define vii vector +#define pq priority_queue > //for min heap. +using namespace std; +vector arr[100001]; +bool vis[100001]; +int col[100001]; +int dx[4]={-1,0,1,0}; +int dy[4]={0,1,0,-1}; +// bool isvalid(int x,int y) +// { +// if(x<1||x>n||y<1||y>m) +// return false; +// if(vis[x][y]==true||ar[x][y]=='#') +// return false; +// return true; +// } +bool dfs(int node,int c) +{ + vis[node]=1; + col[node]=c; + for(auto child :arr[node]) + { + if(!vis[child]) + { + if(dfs(child,c^1)==false) + return false; + } + else + { + if(col[node]==col[child]) + return false; + } + } + return true; +} +int main() +{ + int n,m,a,b; + cin>>n>>m; + while(m--) + { + cin>>a>>b; + arr[a].pb(b); + arr[b].pb(a); + } + bool f=true; + for(int i=1;i<=n;i++) + { + if(!vis[i]) + { + f=dfs(i,0); + if(f==false) + break; + } + } + if(!f) cout<<"IMPOSSIBLE"< Date: Sun, 3 Oct 2021 00:33:04 +0530 Subject: [PATCH 2/4] Create 660.cpp --- 660.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 660.cpp diff --git a/660.cpp b/660.cpp new file mode 100644 index 0000000..043952a --- /dev/null +++ b/660.cpp @@ -0,0 +1,61 @@ +#include +#define IOS \ + ios::sync_with_stdio(0); \ + cin.tie(0); \ + cout.tie(0); +#define endl "\n" +#define ll long long int +#define pb push_back +#define pf push_front +#define ma make_pair +#define f1(i, a, b) for (int i = a; i < b; i++) +#define f2(i, a, b) for (int i = a; i > b; i--) +#define ff first +#define ss second +#define lb lower_bound +#define ub upper_bound +#define mod 1000000007 +#define ii pair +#define vi vector +#define vl vector +#define vii vector +#define pq priority_queue > //for min heap. +using namespace std; +vector primefactor(ll n) +{ + vl prime; + for(ll i=2;i*i<=n;i++) + { if(n%i==0) + { + while(n%i==0) + { prime.pb(i); n/=i;} + + } + } + if(n>1) prime.pb(n); + return prime; +} +bool t(ll a,ll b,ll c) +{ + if((a+b)>c&&(b+c)>a&&(c+a)>b) + return true; + return false; +} +int main() +{ IOS; + int t; + cin>>t; + while(t--) + { + int n; + cin>>n; + int x=ceil(1.0*n/4); // no of 8 ; + // no of 9 = n-x; + for(int i=0;i Date: Sun, 3 Oct 2021 00:39:13 +0530 Subject: [PATCH 3/4] Create 766.cpp --- 766.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 766.cpp diff --git a/766.cpp b/766.cpp new file mode 100644 index 0000000..165d436 --- /dev/null +++ b/766.cpp @@ -0,0 +1,63 @@ +#include +#define IOS \ + ios::sync_with_stdio(0); \ + cin.tie(0); \ + cout.tie(0); +#define endl "\n" +#define ll long long int +#define pb push_back +#define pf push_front +#define ma make_pair +#define f1(i, a, b) for (int i = a; i < b; i++) +#define f2(i, a, b) for (int i = a; i > b; i--) +#define ff first +#define ss second +#define lb lower_bound +#define ub upper_bound +#define mod 1000000007 +#define ii pair +#define vi vector +#define vl vector +#define vii vector +#define pq priority_queue > //for min heap. +using namespace std; +vector primefactor(ll n) +{ + vl prime; + for(ll i=2;i*i<=n;i++) + { if(n%i==0) + { + while(n%i==0) + { prime.pb(i); n/=i;} + + } + } + if(n>1) prime.pb(n); + return prime; +} +bool t(ll a,ll b,ll c) +{ + if((a+b)>c&&(b+c)>a&&(c+a)>b) + return true; + return false; +} +int main() +{ IOS; + + ll n; + cin>>n; + vl a(n); + for(ll i=0;i>a[i]; + sort(a.begin(),a.end()); + bool f=false; + for(ll i=0;i Date: Sun, 3 Oct 2021 00:41:10 +0530 Subject: [PATCH 4/4] Create 90a.cpp --- 90a.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 90a.cpp diff --git a/90a.cpp b/90a.cpp new file mode 100644 index 0000000..5fff316 --- /dev/null +++ b/90a.cpp @@ -0,0 +1,53 @@ +#include +#define IOS \ + ios::sync_with_stdio(0); \ + cin.tie(0); \ + cout.tie(0); +#define endl "\n" +#define ll long long int +#define pb push_back +#define pf push_front +#define ma make_pair +#define f1(i, a, b) for (int i = a; i < b; i++) +#define f2(i, a, b) for (int i = a; i > b; i--) +#define ff first +#define ss second +#define lb lower_bound +#define ub upper_bound +#define mod 1000000007 +#define ii pair +#define vi vector +#define vl vector +#define vii vector +#define pq priority_queue > //for min heap. +using namespace std; +vector primefactor(ll n) +{ + vl prime; + for(ll i=2;i*i<=n;i++) + { if(n%i==0) + { + while(n%i==0) + { prime.pb(i); n/=i;} + + } + } + if(n>1) prime.pb(n); + return prime; +} +int main() +{ IOS; + int t; + cin>>t; + while(t--) + { + ll a,b,c; + cin>>a>>b>>c; + if(a