Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create building.cpp #117

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions 660.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <bits/stdc++.h>
#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<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define pq priority_queue<int,vi,greater<int> > //for min heap.
using namespace std;
vector<ll> 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<n-x;i++)
cout<<9;
for(int i=0;i<x;i++)
cout<<8;
cout<<endl;
}

}
63 changes: 63 additions & 0 deletions 766.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include <bits/stdc++.h>
#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<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define pq priority_queue<int,vi,greater<int> > //for min heap.
using namespace std;
vector<ll> 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<n;i++) cin>>a[i];
sort(a.begin(),a.end());
bool f=false;
for(ll i=0;i<n-2;i++)
{
f=t(a[i],a[i+1],a[i+2]);
if(f)
{ cout<<"YES"<<endl;
break;
}
}
if(!f) cout<<"NO"<<endl;

}
53 changes: 53 additions & 0 deletions 90a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <bits/stdc++.h>
#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<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define pq priority_queue<int,vi,greater<int> > //for min heap.
using namespace std;
vector<ll> 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<c)
cout<<1<<" ";
else cout<<-1<<" ";
if(c<a*b)
cout<<b<<endl;
else cout<<-1<<endl;
}
}
83 changes: 83 additions & 0 deletions building.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#include <bits/stdc++.h>
#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<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define pq priority_queue<int,vi,greater<int> > //for min heap.
using namespace std;
vector<int> 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"<<endl;
else
{
for(int i=1;i<=n;i++)
cout<<col[i]+1<<" ";

}

}