Skip to content

Commit f49d3b9

Browse files
committed
5 cf problems + python stack file fix
1 parent eed00b9 commit f49d3b9

File tree

7 files changed

+111
-2
lines changed

7 files changed

+111
-2
lines changed

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"ostream": "cpp",
66
"iostream": "cpp",
77
"string": "cpp",
8-
"istream": "cpp"
8+
"istream": "cpp",
9+
"iosfwd": "cpp"
910
},
1011
"C_Cpp.intelliSenseEngineFallback": "Disabled"
1112
}

codeforces/1632A.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main() {
5+
ios::sync_with_stdio(false);
6+
cin.tie(0);
7+
int t; cin >> t;
8+
while(t--){
9+
int n; cin >> n;
10+
string s; cin >> s;
11+
if(s == "0" || s == "1" || s == "01" || s == "10") cout << "YES\n";
12+
else cout << "NO\n";
13+
}
14+
15+
return 0;
16+
}

codeforces/490A.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main() {
5+
ios::sync_with_stdio(false);
6+
cin.tie(0);
7+
int n,i,a[4][5050],b[4],c,d;
8+
cin>>n;
9+
for(i=1;i<=n;i++)
10+
{
11+
cin>>c;
12+
a[c][b[c]++]=i;
13+
}
14+
d=min(b[1],min(b[2],b[3]));
15+
cout<<d<<endl;
16+
for(i=0;i<d;i++)
17+
{
18+
cout<<a[1][i]<<" "<<a[2][i]<<" "<<a[3][i]<<endl;
19+
}
20+
return 0;
21+
}

codeforces/59A.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main() {
5+
ios::sync_with_stdio(false);
6+
cin.tie(0);
7+
string s; cin >> s;
8+
int upper_cnt = 0;
9+
int lower_cnt = 0;
10+
for(char c : s) {
11+
if(isupper(c)) upper_cnt++;
12+
else lower_cnt++;
13+
}
14+
if(upper_cnt > lower_cnt) {
15+
transform(s.begin(), s.end(), s.begin(), ::toupper);
16+
}
17+
else {
18+
transform(s.begin(), s.end(), s.begin(), ::tolower);
19+
}
20+
cout << s;
21+
return 0;
22+
}

codeforces/977A.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main() {
5+
ios::sync_with_stdio(false);
6+
cin.tie(0);
7+
int n, k; cin >> n >> k;
8+
9+
for(int i = 0; i < k; i++) {
10+
if(n % 10 == 0) n /= 10;
11+
else n -= 1;
12+
}
13+
cout << n;
14+
15+
return 0;
16+
}

codeforces/977B.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
template<typename KeyType, typename ValueType>
5+
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
6+
using pairtype=std::pair<KeyType,ValueType>;
7+
return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
8+
return p1.second < p2.second;
9+
});
10+
}
11+
12+
int main() {
13+
ios::sync_with_stdio(false);
14+
cin.tie(0);
15+
int n; cin >> n;
16+
string s; cin >> s;
17+
vector<string> v;
18+
19+
for(int i = 0; i < n-1; i++) {
20+
string tg = "";
21+
tg.push_back(s[i]); tg.push_back(s[i+1]);
22+
v.push_back(tg);
23+
}
24+
map<string, int> counters;
25+
for(auto i : v) {
26+
++counters[i];
27+
}
28+
29+
auto max = get_max(counters);
30+
cout << max.first;
31+
32+
return 0;
33+
}

cs-article-snippets/stack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ def is_empty(self):
2323
return False
2424

2525
if __name__ == '__main__':
26-
stack = stack()
26+
my_stack = stack()
2727

2828

0 commit comments

Comments
 (0)