Skip to content

Commit b813fc3

Browse files
author
Kiran Patil
authored
Add files via upload
1 parent 6962b84 commit b813fc3

12 files changed

Lines changed: 248 additions & 0 deletions

BeatsTheOdd.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include<iostream>
2+
using namespace std;
3+
int main()
4+
{
5+
int t;
6+
cin>>t;
7+
// int r=0;
8+
//int a[t];
9+
while(t--)
10+
{
11+
int n;
12+
cin>>n;
13+
int e=0,o=0;
14+
int arr[n];
15+
for(int i=0;i<n;i++)
16+
{
17+
cin>>arr[i];
18+
if(arr[i]%2==0)
19+
e++;
20+
else
21+
o++;
22+
}
23+
if(o<e)
24+
cout<<o<<endl;
25+
else
26+
cout<<e<<endl;
27+
28+
29+
}
30+
31+
32+
33+
}

BeatsTheOdd.exe

44 KB
Binary file not shown.

D806.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include<bits/stdc++.h>
2+
#define int long long int
3+
using namespace std;
4+
bool check(vector<string> &kp int k){
5+
for(int i=0;i<kp[k].size();i++){
6+
string k1=kp[k];
7+
k1.erase(i+1,k1.size()i-1);
8+
string k2=kp[i];
9+
k2.erase(0,i+1)
10+
if(find(kp.begin(),kp.end(),k1)!=kp.end() && find(kp.begin(),kp.end(),k2)!=kp.end()){
11+
return true;
12+
}
13+
}
14+
return false;
15+
}
16+
signed main()
17+
{
18+
int t;
19+
cin>>t;
20+
while(t--)
21+
{
22+
int n;
23+
cin>>n;
24+
vector<string>kp;
25+
for(int i=0;i<n;i++)
26+
{
27+
string str;
28+
cin>>str;
29+
kp.push_back(str);
30+
}
31+
vector<int>result;
32+
for(int i=0;i<n;i++){
33+
result.push_back(check(kp,i));
34+
}
35+
for(auto &ele : result)
36+
{
37+
cout<<ele;
38+
}
39+
cout<<endl;
40+
41+
}
42+
}

ICPCBallon.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
int main()
4+
{
5+
int test;
6+
cin>>test;
7+
while(test--)
8+
{
9+
int n;
10+
cin>>n;
11+
unordered_map<char,int>kp;
12+
for(int i=0;i<n;i++)
13+
{
14+
char k;cin>>k;kp[k]++;
15+
}
16+
int result=0;
17+
for(auto x:kp)
18+
{
19+
int k1=(x.second-1);
20+
int k2=2;
21+
result+=k1+k2;
22+
}
23+
cout<<result<<endl;
24+
}
25+
}

ICPCBallon.exe

124 KB
Binary file not shown.

PoliceStation.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
5+
// } Driver Code Ends
6+
//User function Template for C++
7+
8+
class Solution {
9+
public:
10+
int solve(int N, int a, vector<int> x)
11+
{
12+
sort(x.begin(),x.end());
13+
int k=x.size()-1;
14+
int s=0;
15+
int c=0;
16+
for(int i=k;c<=2;i--)
17+
{
18+
if(x[k]!=x[k-1])
19+
{
20+
s+=(abs(x[k]-a));
21+
c++;
22+
23+
}
24+
else
25+
{
26+
s+=(abs(x[k]-a));
27+
}
28+
29+
30+
}
31+
return s;
32+
// code here
33+
}
34+
};
35+
36+
// { Driver Code Starts.
37+
int main() {
38+
int T;
39+
cin >> T;
40+
while (T--) {
41+
42+
int N, a;
43+
cin >> N >> a;
44+
45+
46+
vector<int> x(N);
47+
for (int i = 0; i < N; i++)
48+
cin >> x[i];
49+
50+
Solution ob;
51+
cout << ob.solve(N, a, x) << "\n";
52+
}
53+
return 0;
54+
}
55+
// } Driver Code Ends

PoliceStation.exe

88.5 KB
Binary file not shown.

YESisYES.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
int main()
4+
{
5+
int t;
6+
cin>>t;
7+
while(t--)
8+
{
9+
string str;
10+
cin>>str;
11+
for(int i=0;i<str.size();i++)
12+
{
13+
if(str[i]>='A' && str[i]<='Z')
14+
str[i]+=32;
15+
}
16+
if(str[0]=='y' && str[1]=='e' && str[2]=='s')
17+
cout<<"YES"<<endl;
18+
else
19+
cout<<"NO"<<endl;
20+
}
21+
}

cypher.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
int main()
4+
{
5+
int t;
6+
cin>>t;
7+
while(t--)
8+
{
9+
int n;
10+
cin>>n;
11+
vector<int>kp;
12+
for(int i=0;i<n;i++)
13+
{
14+
int v;
15+
cin>>v;
16+
kp.push_back(v);
17+
}
18+
for(int i=0;i<n;i++)
19+
{
20+
int l;
21+
cin>>l;
22+
string s;
23+
cin>>s;
24+
for(int j=0;j<l;j++)
25+
{
26+
if(s[j]=='U'){
27+
if(kp[i]==0){
28+
kp[i]=9;
29+
}
30+
else{
31+
kp[i]-=1;
32+
}
33+
}
34+
else if(s[j]=='D'){
35+
kp[i]=(kp[i]+1)%10;
36+
}
37+
38+
}
39+
}
40+
for(auto &ele:kp){
41+
cout<<ele<<" ";
42+
}cout<<endl;
43+
}
44+
return 0;
45+
}

cypher.exe

70 KB
Binary file not shown.

0 commit comments

Comments
 (0)