Posts

Showing posts from June, 2019

Pattern ;)

/* ─────────▄──────────────▄─────────wow───────────────────────────────────── ────────▌▒█───────────▄▀▒▌──────────────────────────────────────────────── ────────▌▒▒█────────▄▀▒▒▒▐──────────────────────────────────────────────── ───────▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐────────────▄▄▄▄─▄▄▄▄────▄▄▄▄─▄▄▄▄─▄▄▄▄─▄─────── ─────▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐────────────█▄▄▄─█──█────█────█──█─█──█─█─────── ───▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌────────────▄▄▄█─█▄▄█────█▄▄▄─█▄▄█─█▄▄█─█▄▄▄──── ──▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒▌─────────────────────────────────────────────── ──▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐─────────────────────────────────────────────── ─▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌─────────────────so─ascii───────────────────── ─▌░▒▄██▄▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌────────────────────────────────────────────── ▀▒▀▐▄█▄█▌▄░▀▒▒░░░░░░░░░░▒▒▒▐────much─codeforces─────────────────────────── ▐▒▒▐▀▐▀▒░▄▄▒▄▒▒▒▒▒▒░▒░▒░▒▒▒▒▌──────────────────────────────────────omg──── ▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒▒▒░▒░▒░▒▒▐───────────▄─────▄─▄▄▄▄─▄─────▄─────────────── ─▌▒▒▒▒▒...

UVA 673(using stack)

/* ID: Nipun Paul LANG: C++ PROB: God knows */ #include<bits/stdc++.h> using namespace std; int main() {     int a,flag;     cin>>a;     getchar();     for(int i=0; i<a; i++)     {     string b;     getline(cin,b);     stack<char> st;     for(int i=0; i<b.size(); i++)     {         if(b[i]=='(' || b[i]=='[' || b[i]==' ')         {             st.push(b[i]);         }         else if(b[i]==')')         {             if(!st.empty() && st.top()=='(')             {                 st.pop();             }             else       ...

Bool check prime or not

Not time efficient. /* ID: Nipun Paul LANG: C++ PROB: God knows */ #include<bits/stdc++.h> using namespace std; bool checkPrime(int p) {     if(p==1)     {         return false;     }     else if(p==2)     {         return true;     }     else     {         for(int i=2; i*i<=p; i++)         {             if(p%i==0)             {                 return false;             }         }         return true;     } } int main() {     int a,b,c,flag;     cin>>a;     for(int i=0; i<a; i++)     {         cin>>b>>c;     ...

UVA 11849(Using set)

/* ID: Nipun Paul LANG: C++ PROB: God knows */ #include<bits/stdc++.h> using namespace std; int main() {     int a,b,c;     set<int> s;     s.clear();     while(cin>>a>>b)     {         if(a+b==0)         {             break;         }         else{         for(int i=0; i<a; i++)         {             cin>>c;             s.insert(c);         }         for(int j=0; j<b; j++)         {             cin>>c;             s.insert(c);         }         cout<<(a+b)-s.size()<<endl;     ...

C++ STL practice problem link

HackerRank: 1.  https://www.hackerrank.com/challenges/variable-sized-arrays/problem 2.  https://www.hackerrank.com/challenges/vector-sort/problem 3.  https://www.hackerrank.com/challenges/c-tutorial-stringstream/problem 4.  https://www.hackerrank.com/challenges/vector-erase/problem?h_r=profile 5.  https://www.hackerrank.com/challenges/cpp-sets/problem?h_r=profile 6.  https://www.hackerrank.com/challenges/cpp-lower-bound/problem?h_r=profile 7.  https://www.hackerrank.com/challenges/cpp-maps/problem Stable_Sort: 1 .  https://vjudge.net/contest/307320#status/Nipun_Paul/P/0/ Details:  https://www.geeksforgeeks.org/stable_sort-c-stl/ General Sort: 1.  https://vjudge.net/contest/307320#status/Nipun_Paul/R/0/ Queue 1.  https://vjudge.net/contest/307320#status/Nipun_Paul/C/0/ Details:  https://www.geeksforgeeks.org/queue-cpp-stl/ List 1. https://vjudge.net/contest/307320#status/Nipun_Paul/F/0/ Details:  ht...

UVA 102

Input matters here,as we use while,without it I have got 3 wa.BUT when i  use int instead of lli,i got .010 sec more,thats why I am confused why so. #include<bits/stdc++.h> using namespace std; int main() {     long long int a0,a1,a2,a3,a4,a5,a6,a7,a8,b[6],d[6],bgc=0,bcg=0,gbc=0,gcb=0,cbg=0,cgb=0;     string c[6];     while(cin>>a0>>a1>>a2>>a3>>a4>>a5>>a6>>a7>>a8){     bgc=a3+a6+a1+a7+a2+a5;     bcg=a3+a6+a2+a8+a1+a4;     gbc=a4+a7+a0+a6+a2+a5;     gcb=a4+a7+a2+a8+a0+a3;     cbg=a5+a8+a0+a6+a1+a4;     cgb=a5+a8+a1+a7+a0+a3;     b[1]=bgc;     c[1]="BGC";     b[0]=bcg;     c[0]="BCG";     b[4]=gbc;     c[4]="GBC";     b[5]=gcb;     c[5]="GCB";     b[2]=cbg;     c[2]="CBG";     b[3]=cgb;     c[...

UVA 495

#include<bits/stdc++.h> #include<boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; using namespace std; int main() {     long long int c=0,sum=0;     cpp_int a=0;     cpp_int b=1;     cpp_int d=0;     while(cin>>c){     while(sum!=c && c!=1 && c!=0)     {         d=a+b;         a=b;         b=d;         sum++;     }     if(c==0)     {         cout<<"The Fibonacci number for "<<c<<" is 0"<<endl;     }     else if(c==1)     {         cout<<"The Fibonacci number for "<<c<<" is 1"<<endl;     }     else     {         cout<<"The Fibonacci number for "<<c...