Skip to content

Commit f6f9966

Browse files
committed
cc contest
1 parent 324de65 commit f6f9966

23 files changed

+2330
-4
lines changed

Codechef/ICM2021B/ICM0001.cpp

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
Institute: National Institute of Technology, Uttarakhand
5+
*/
6+
#include <bits/stdc++.h>
7+
#include <ext/pb_ds/assoc_container.hpp>
8+
#include <ext/pb_ds/tree_policy.hpp>
9+
using namespace std;
10+
using namespace __gnu_pbds;
11+
typedef long long ll ;
12+
typedef unsigned long long ull;
13+
typedef vector<ll> vl;
14+
#define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
15+
/* Abbrevations */
16+
#define ff first
17+
#define ss second
18+
#define mp make_pair
19+
#define line cout<<endl;
20+
#define pb push_back
21+
#define Endl "\n"
22+
// loops
23+
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
24+
// Some print
25+
#define no cout<<"NO"<<endl;
26+
#define yes cout<<"YES"<<endl;
27+
// sort
28+
#define all(V) (V).begin(),(V).end()
29+
#define srt(V) sort(all(V))
30+
#define srtGreat(V) sort(all(V),greater<ll>())
31+
// some extra
32+
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
33+
#define precision(x) cout<<fixed<<setprecision(x);
34+
#define sz(V) ll(V.size())
35+
// template
36+
template <typename T>
37+
T mymax(T x,T y)
38+
{
39+
return (x>y)?x:y;
40+
}
41+
// function
42+
ll power(ll x,ll y,ll mod)
43+
{
44+
ll res=1;
45+
// x=x%mod;
46+
while(y>0)
47+
{
48+
if(y%2==1)
49+
{
50+
res*=x;
51+
// res=res%mod;
52+
}
53+
y/=2; x*=x; // x=x%mod;
54+
}
55+
return res;
56+
}
57+
ll str_to_num(string s)
58+
{
59+
stringstream pk(s);
60+
ll num;
61+
pk>>num;
62+
return num;
63+
}
64+
65+
string num_to_str(ll num)
66+
{
67+
return to_string(num);
68+
}
69+
// datatype definination
70+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
71+
class Point
72+
{
73+
public:
74+
ll x;
75+
ll y;
76+
ll z;
77+
ll getsum()
78+
{
79+
return x+y+z;
80+
}
81+
};
82+
/* ascii value
83+
A=65,Z=90,a=97,z=122
84+
*/
85+
/* --------------------MAIN PROGRAM----------------------------*/
86+
// to run ctrl+b
87+
const ll INF=LONG_MAX;
88+
const ll mod1=1e9+7;
89+
const ll mod2=998244353;
90+
91+
ll solve()
92+
{
93+
ll n;
94+
cin>>n;
95+
vl v(n);
96+
forin(v,n);
97+
ll pos=0,temp_pos=0;
98+
ll pre=v[n-1];
99+
for(ll i=n-1;i>=0;i--){
100+
if(v[i]<=pre){
101+
pre=v[i];
102+
continue;
103+
}
104+
else{
105+
temp_pos=i+1;
106+
break;
107+
}
108+
}
109+
pre=v[0];
110+
ll temp_pos2=0;
111+
for(ll i=0;i<n;i++){
112+
if(v[i]>=pre){
113+
pre=v[i];
114+
continue;
115+
}
116+
else{
117+
temp_pos2=i;
118+
break;
119+
}
120+
}
121+
if(temp_pos==temp_pos2){
122+
if(temp_pos2==0){
123+
yes
124+
cout<<0<<endl;
125+
}
126+
else if(v[0]>=v[n-1]){
127+
yes
128+
cout<<1<<endl;
129+
}
130+
else
131+
no
132+
133+
}
134+
else
135+
no
136+
return 0;
137+
}
138+
139+
int main()
140+
{
141+
speed;
142+
/* #ifndef ONLINE_JUDGE
143+
freopen("input.txt","r",stdin);
144+
freopen("output.txt","w",stdout);
145+
#endif */
146+
ll TestCase=1;
147+
cin>>TestCase;
148+
while(TestCase--)
149+
{
150+
solve();
151+
}
152+
}
153+
/* -----------------END OF PROGRAM --------------------*/
154+
/*
155+
* stuff you should look before submission
156+
* constraint and time limit
157+
* int overflow
158+
* special test case (n=0||n=1||n=2)
159+
* don't get stuck on one approach if you get wrong answer
160+
*/

Codechef/ICM2021B/ICM0003.cpp

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
Institute: National Institute of Technology, Uttarakhand
5+
*/
6+
#include <bits/stdc++.h>
7+
#include <ext/pb_ds/assoc_container.hpp>
8+
#include <ext/pb_ds/tree_policy.hpp>
9+
using namespace std;
10+
using namespace __gnu_pbds;
11+
typedef long long ll ;
12+
typedef unsigned long long ull;
13+
typedef vector<ll> vl;
14+
#define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
15+
/* Abbrevations */
16+
#define ff first
17+
#define ss second
18+
#define mp make_pair
19+
#define line cout<<endl;
20+
#define pb push_back
21+
#define Endl "\n"
22+
// loops
23+
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
24+
// Some print
25+
#define no cout<<"NO"<<endl;
26+
#define yes cout<<"YES"<<endl;
27+
// sort
28+
#define all(V) (V).begin(),(V).end()
29+
#define srt(V) sort(all(V))
30+
#define srtGreat(V) sort(all(V),greater<ll>())
31+
// some extra
32+
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
33+
#define precision(x) cout<<fixed<<setprecision(x);
34+
#define sz(V) ll(V.size())
35+
// template
36+
template <typename T>
37+
T mymax(T x,T y)
38+
{
39+
return (x>y)?x:y;
40+
}
41+
// function
42+
ll power(ll x,ll y,ll mod)
43+
{
44+
ll res=1;
45+
// x=x%mod;
46+
while(y>0)
47+
{
48+
if(y%2==1)
49+
{
50+
res*=x;
51+
// res=res%mod;
52+
}
53+
y/=2; x*=x; // x=x%mod;
54+
}
55+
return res;
56+
}
57+
ll str_to_num(string s)
58+
{
59+
stringstream pk(s);
60+
ll num;
61+
pk>>num;
62+
return num;
63+
}
64+
65+
string num_to_str(ll num)
66+
{
67+
return to_string(num);
68+
}
69+
// datatype definination
70+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
71+
class Point
72+
{
73+
public:
74+
ll x;
75+
ll y;
76+
ll z;
77+
ll getsum()
78+
{
79+
return x+y+z;
80+
}
81+
};
82+
/* ascii value
83+
A=65,Z=90,a=97,z=122
84+
*/
85+
/* --------------------MAIN PROGRAM----------------------------*/
86+
// to run ctrl+b
87+
const ll INF=LONG_MAX;
88+
const ll mod1=1e9+7;
89+
const ll mod2=998244353;
90+
const double pi=3.1415926535;
91+
92+
ll solve()
93+
{
94+
ll n;
95+
cin>>n;
96+
double angle=(double)(180*(n-2))/n;
97+
angle=(180.0-angle)/2;
98+
angle=(angle*(pi/180));
99+
cout<<fixed<<setprecision(20);
100+
double r=(double)cos(angle);
101+
r=r*r;
102+
r=1.0-r;
103+
r=1/r;
104+
cout<<r<<endl;
105+
return 0;
106+
}
107+
108+
int main()
109+
{
110+
speed;
111+
/* #ifndef ONLINE_JUDGE
112+
freopen("input.txt","r",stdin);
113+
freopen("output.txt","w",stdout);
114+
#endif */
115+
ll TestCase=1;
116+
cin>>TestCase;
117+
while(TestCase--)
118+
{
119+
solve();
120+
}
121+
}
122+
/* -----------------END OF PROGRAM --------------------*/
123+
/*
124+
* stuff you should look before submission
125+
* constraint and time limit
126+
* int overflow
127+
* special test case (n=0||n=1||n=2)
128+
* don't get stuck on one approach if you get wrong answer
129+
*/

Template.cpp renamed to Codechef/ICM2021B/ICM0013.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/*
22
written by Pankaj Kumar.
33
country:-INDIA
4+
Institute: National Institute of Technology, Uttarakhand
45
*/
56
#include <bits/stdc++.h>
67
#include <ext/pb_ds/assoc_container.hpp>
78
#include <ext/pb_ds/tree_policy.hpp>
89
using namespace std;
910
using namespace __gnu_pbds;
1011
typedef long long ll ;
12+
typedef unsigned long long ull;
1113
typedef vector<ll> vl;
1214
#define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
1315
/* Abbrevations */
@@ -28,6 +30,7 @@ typedef vector<ll> vl;
2830
#define srtGreat(V) sort(all(V),greater<ll>())
2931
// some extra
3032
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
33+
#define precision(x) cout<<fixed<<setprecision(x);
3134
#define sz(V) ll(V.size())
3235
// template
3336
template <typename T>
@@ -53,7 +56,10 @@ ll power(ll x,ll y,ll mod)
5356
}
5457
ll str_to_num(string s)
5558
{
56-
return stoi(s);
59+
stringstream pk(s);
60+
ll num;
61+
pk>>num;
62+
return num;
5763
}
5864

5965
string num_to_str(ll num)
@@ -76,11 +82,17 @@ class Point
7682
/* ascii value
7783
A=65,Z=90,a=97,z=122
7884
*/
79-
/* -----------------------------------------------------------------------------------*/
85+
/* --------------------MAIN PROGRAM----------------------------*/
8086
// to run ctrl+b
87+
const ll INF=LONG_MAX;
88+
const ll mod1=1e9+7;
89+
const ll mod2=998244353;
8190

8291
ll solve()
8392
{
93+
ll n;
94+
cin>>n;
95+
cout<<n<<endl;
8496
return 0;
8597
}
8698

@@ -98,8 +110,10 @@ int main()
98110
solve();
99111
}
100112
}
101-
102-
/* stuff you should look before submission
113+
/* -----------------END OF PROGRAM --------------------*/
114+
/*
115+
* stuff you should look before submission
116+
* constraint and time limit
103117
* int overflow
104118
* special test case (n=0||n=1||n=2)
105119
* don't get stuck on one approach if you get wrong answer

Codechef/ICM2021B/a.out

33.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)