Skip to content

Commit a9ee9b2

Browse files
committed
a2oj added
1 parent 24561b2 commit a9ee9b2

File tree

5 files changed

+210
-0
lines changed

5 files changed

+210
-0
lines changed

A2OJ/A/031. Cakeminator.cpp

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#include <bits/stdc++.h>
2+
#define lli long long int
3+
#define endl "\n"
4+
using namespace std;
5+
6+
int main()
7+
{
8+
int n, m;
9+
cin>>n>>m;
10+
int a[n][m],flag =0;
11+
string s[n];
12+
for(int i=0; i<n; i++)
13+
cin>>s[i];
14+
for(int i=0; i<n; i++)
15+
{
16+
for(int j=0; j<m; j++)
17+
{
18+
if(s[i][j] == '.')
19+
a[i][j] = 0;
20+
else
21+
a[i][j]= -1;
22+
}
23+
}
24+
for(int i=0; i<n; i++)
25+
{
26+
flag =0;
27+
for(int j=0; j<m; j++)
28+
{
29+
if(a[i][j] == -1)
30+
{
31+
flag =1;
32+
break;
33+
}
34+
}
35+
if(flag == 0)
36+
{
37+
for(int j=0; j<m; j++)
38+
{
39+
a[i][j] = 1;
40+
}
41+
}
42+
}
43+
for(int j=0; j<m; j++)
44+
{
45+
flag =0;
46+
for(int i=0; i<n; i++)
47+
{
48+
if(a[i][j] == -1)
49+
{
50+
flag =1;
51+
break;
52+
}
53+
}
54+
if(flag == 0)
55+
{
56+
for(int i=0; i<n; i++)
57+
{
58+
a[i][j] = 1;
59+
}
60+
}
61+
}
62+
int count = 0;
63+
for(int i=0; i<n; i++)
64+
{
65+
for(int j=0; j<m; j++)
66+
{
67+
if((a[i][j] == 1))
68+
count++;
69+
}
70+
}
71+
cout<<count;
72+
return 0;
73+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <bits/stdc++.h>
2+
#define lli long long int
3+
#define endl "\n"
4+
using namespace std;
5+
6+
int main()
7+
{
8+
lli n,v,cost,ans = 0;
9+
cin>>n>>v;
10+
vector <int> v1;
11+
int k,flag;
12+
for(int i =0; i<n; i++)
13+
{
14+
cin>>k;
15+
flag = 0;
16+
for(int j = 1; j<= k; j++)
17+
{
18+
cin>>cost;
19+
if(cost < v)
20+
flag = 1;
21+
}
22+
if(flag == 1)
23+
{
24+
v1.push_back(i+1);
25+
ans += 1;
26+
}
27+
}
28+
cout<<ans<<endl;
29+
for(auto c: v1)
30+
cout<<c<<" ";
31+
32+
return 0;
33+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include <bits/stdc++.h>
2+
#define lli long long int
3+
#define endl "\n"
4+
using namespace std;
5+
6+
int main()
7+
{
8+
int n,flag =0;
9+
cin>>n;
10+
string a[n];
11+
for(int i=0; i<n; i++)
12+
cin>>a[i];
13+
for(int i=0 ;i<n; i++)
14+
{
15+
int count = 0;
16+
for(int j=0; j<n; j++)
17+
{
18+
if((i-1 >= 0) and (a[i-1][j] == 'o')){
19+
count++;
20+
//cout<<"YES1"<<end;
21+
}
22+
if((i+1 < n) and (a[i+1][j] == 'o')){
23+
count++;
24+
//cout<<"YES2"<<end;
25+
}
26+
if((j-1 >= 0) and (a[i][j-1] == 'o')){
27+
count++;
28+
//cout<<"YES3"<<end;
29+
}
30+
if((j+1 < n) and (a[i][j+1] == 'o')){
31+
count++;
32+
//cout<<"YES4"<<end;
33+
}
34+
if((count %2) != 0)
35+
{
36+
flag =1;
37+
break;
38+
}
39+
}
40+
if(flag == 1)
41+
break;
42+
43+
}
44+
if(flag == 0)
45+
cout<<"YES";
46+
else
47+
cout<<"NO";
48+
49+
50+
return 0;
51+
}

A2OJ/A/034. Bear and Raspberry.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <bits/stdc++.h>
2+
#define lli long long int
3+
#define endl "\n"
4+
using namespace std;
5+
6+
int main()
7+
{
8+
int n,c;
9+
cin>>n>>c;
10+
int a[n];
11+
for(int i=0; i<n; i++)
12+
cin>>a[i];
13+
int maxi = 0;
14+
for(int i=0; i<n-1; i++)
15+
{
16+
int left = a[i] - c;
17+
if(left >= a[i+1])
18+
{
19+
int profit = left - a[i+1];
20+
if(profit > maxi)
21+
maxi = profit;
22+
}
23+
}
24+
cout<<maxi;
25+
26+
return 0;
27+
}

A2OJ/A/035. Lunch Rush.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <bits/stdc++.h>
2+
#define lli long long int
3+
#define endl "\n"
4+
using namespace std;
5+
6+
int main()
7+
{
8+
lli n,k,data1,data2, maxjoy = INT_MIN;
9+
cin>>n>>k;
10+
vector <lli> f,t;
11+
for(int i=0; i<n; i++)
12+
{
13+
cin>>data1>>data2;
14+
lli joy;
15+
if(data2 <= k)
16+
joy = data1;
17+
else
18+
joy = data1 - (data2-k);
19+
if(joy> maxjoy)
20+
maxjoy = joy;
21+
}
22+
cout<<maxjoy;
23+
24+
25+
return 0;
26+
}

0 commit comments

Comments
 (0)