Posts

Showing posts with the label AtCoder

AtCoder Roulette

  #include < bits / stdc ++. h > using namespace std ;   const int high = 205 ;   int ar [ high ][ high ], ans [ high ], allC [ high ], mp [ high ][ high ];   struct data { int indx ; int c ; } sarr [ high ];   void sol ( int N ) { int C , clen = 0 ; for ( int i = 0 ; i < N ; i ++) { cin >> C ; allC [ clen ++] = C ; for ( int j = 0 ; j < C ; j ++) { cin >> ar [ i ][ j ]; } } int X , minC = 37 , slen = 0 ; cin >> X ; for ( int i = 0 ; i < N ; i ++) { for ( int j = 0 ; j < allC [ i ]; j ++) { if ( ar [ i ][ j ] == X ) { if ( mp [ i ][ j ] == 0 ) { mp [ i ][ j ] = 1 ; sarr [ slen ]. indx = i + 1 ; sarr [ slen ++]. c = allC [ i ]; if ( minC > allC [ i ]) { minC =...

AtCoder 3.14

#include < bits / stdc ++. h > using namespace std ;   void sol ( int N , string pi ) { int len = pi . length (); N = 2 + N ; for ( int i = 0 ; i < N ; i ++) { cout << pi [ i ]; } }   int main () { string pi = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679" ; int N ; cin >> N ; sol ( N , pi ); return 0 ; }

AtCode A - To Be Saikyo

 Problem Description Link:  https://atcoder.jp/contests/abc313/tasks/abc313_a Accepted Solution #include <bits/stdc++.h> using namespace std ; int sol ( int N ) {     int i , a , mx = - 1 , first = 0 , cnt = 0 ;     cin >> first ;     mx = max ( mx , first );     for ( i = 1 ; i < N ; i ++ ) {         cin >> a ;         if ( a == first ) {             cnt += 1 ;         }         mx = max ( mx , a );     }         int x = mx - first ;     if ( cnt == 0 && mx != first ) {         return x + 1 ;     }     else if ( cnt == 0 && mx == first ) {         return 0 ;     }     else if ( cnt >= 1 && cnt != ( N - 1 )) { ...

ARC116 - A - Odd vs Even

 /*     There is a pattern to solve this problem:     1 -> odd     2 -> same     3 -> odd     4 -> even     5 -> odd     6 -> same     7 -> odd     8 -> even     9 -> odd     10 -> same     11 -> odd     12 -> even     13 -> odd     14 -> same     15 -> odd     16 -> even     17 -> odd     18 -> same     19 -> odd     20 -> even     Observation:     1. same number of even and odd divisors are repeating after 4 steps     2. we are getting more even number of divisors which is divided by 4     3. a typical odd number is generating much number of odd divisors     Now, let's implement those observations... */ #include <bits/stdc++.h> using namespace std; #define sf ...

Atcode ABC - A - Rotate

 #include<bits/stdc++.h> using namespace std; #define sf scanf #define pf printf const int high=1e3+5; int main() {     string s, ans="";     while(cin >> s)     {         int len = s.length();         for(int i=1; i<len; i++)         {             ans += s[i];         }         ans+=s[0];         cout << ans << "\n";         ans.clear();     }     return 0; }

Atcoder ABC 197 - B - Visibility

/*     Count '.' - from the same row and column and count each     Finally, subtract 3, as (x, y) repeated like 3 times */ #include<bits/stdc++.h> using namespace std; #define sf scanf #define pf printf const int high=1000+5; char adj[high][high]; int main() {     int i, j, h, w, x, y;     cin >> h >> w >> x >> y;     for(i=0; i<h; i++)     {         for(j=0; j<w; j++)         {             cin >> adj[i][j];         }     }     int cnt=0;     x--; y--;     for(i=x; i<h; i++) //row - down     {         if(adj[i][y]=='#') break;         cnt+=1;     }     for(i=x; i>=0; i--) // row - up     {         if(adj[i][y]=='#') break;         cnt+...

Atcoder 4-adjacent

/**   *  @Author: Pranta Sarker   *   */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define pfn(x , k) printf(k , x) #define nl puts("") #define psb push_back #define mset(c,v) memset(c , v , sizeof c) #define loop0(n) for(int i=0; i<n; i++) #define loop1(n) for(int i=1; i<=n; i++) #define mpair(x , y) make_pair(x , y) #define all(x) x.begin(), x.end() #define pi acos(-1.0) #define psb push_back #define clr clear() typedef unsigned long long ull; typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef vector<string>vs; typedef map<int, int>mpii; typedef map<string, int>mpsi; typedef map<char, int>mpci; typedef map<LL, LL>mpll; const int mod = 1000007; const int high = 1e5+3; int main() {   ...

Atcoder Write and Erase

/**   *  @Author: Pranta Sarker   *   */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define pfn(x , k) printf(k , x) #define nl puts("") #define psb push_back #define mset(c,v) memset(c , v , sizeof c) #define loop0(n) for(int i=0; i<n; i++) #define loop1(n) for(int i=1; i<=n; i++) #define mpair(x , y) make_pair(x , y) #define all(x) x.begin(), x.end() #define pi acos(-1.0) #define psb push_back #define clr clear() typedef unsigned long long ull; typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef vector<string>vs; typedef map<int, int>mpii; typedef map<string, int>mpsi; typedef map<char, int>mpci; typedef map<LL, LL>mpll; const int mod = 1000007; const int high = 1e5+2; mpii mp; int ma...

AtCoder C - Make a Rectangle

#include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0) typedef long long LL; typedef vector<LL>vll; typedef map<LL, LL>mplli; vll v; mplli mp; set<LL>st; int main() {     fast;     int N;     cin >> N;     int i;     for(i=0; i<N; i++)     {         LL x;         cin >> x;         st.insert(x);         mp[x]++;     }     set<LL>::iterator it;     for(it=st.begin(); it!=st.end(); it++)     {         // cout << *it << "; ";         v.push_back(*it);     }     int len = v.size();     LL mul = 1;  ...

AtCoder Be Together

//#include<stdio.h> //#include<iostream> //#include<algorithm> //#include<vector> //#include<cstring> //#include<cmath> //#include<map> #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; int main() {     fast;     int n;     vii v;     while(cin >> n)     {         v.clear();         int i=0 , x;         for(; i<n; i++)         {             cin >> x;            ...