Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0670c3d

Browse files
Merge pull request #153 from wendirad/openkattis
Add OpenKattis solutions
2 parents 48e25ae + b00a12b commit 0670c3d

File tree

45 files changed

+626
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+626
-0
lines changed

‎OpenKattis/basicprogramming1/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<img src="problem.png" />
292 KB
Loading[フレーム]
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
int main(){
6+
#define int long long
7+
int N, t; cin >> N >> t;
8+
int arr[N+5];
9+
int sum = 0;
10+
int even = 0;
11+
string alp = "abcdefghijklmnopqrstuvwxyz";
12+
string str = "";
13+
for (int i = 0; i < N; i++){
14+
int in;
15+
cin >> in;
16+
arr[i] = in;
17+
sum += in;
18+
if (in % 2 == 0){
19+
even += in;
20+
}
21+
str += alp[in % 26];
22+
}
23+
if (t == 1){
24+
cout << 7 << endl;
25+
} else if (t == 2){
26+
if (arr[0] > arr[1]){
27+
cout << "Bigger\n";
28+
} else if (arr[0] == arr[1]){
29+
cout << "Equal\n";
30+
} else {
31+
cout << "Smaller\n";
32+
}
33+
} else if (t == 3) {
34+
int arr1[] = {arr[0], arr[1], arr[2]};
35+
sort(arr1, arr1+3);
36+
cout << arr1[1] << endl;
37+
} else if (t == 4){
38+
cout << sum << endl;
39+
} else if(t == 5){
40+
cout << even << endl;
41+
} else if (t == 6){
42+
cout << str << endl;
43+
} else {
44+
int index = 0;
45+
int count = 0;
46+
while(index < (N-1) && count++ <= N){
47+
// cout << "C: " << count << endl;
48+
index = arr[index];
49+
}
50+
if (index > (N-1)){
51+
cout << "Out\n";
52+
} else if (index == (N-1)){
53+
cout << "Done\n";
54+
} else {
55+
cout << "Cyclic\n";
56+
}
57+
}
58+
}

‎OpenKattis/calculator/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<img src="problem.png" />

‎OpenKattis/calculator/problem.png

132 KB
Loading[フレーム]

‎OpenKattis/calculator/solution.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
try:
2+
while True:
3+
print("%.2f"%eval(input()))
4+
except:
5+
pass

‎OpenKattis/dyslectionary/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<img src="problem.png" />

‎OpenKattis/dyslectionary/problem.png

187 KB
Loading[フレーム]

‎OpenKattis/dyslectionary/solution.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include <algorithm>
2+
#include <iostream>
3+
#include <vector>
4+
#include <string>
5+
6+
using namespace std;
7+
8+
void process(vector<string>& v) {
9+
// Find the max length for each string
10+
int maxlen = 0;
11+
for(auto i : v) {
12+
if(i.length() > maxlen) {
13+
maxlen = i.length();
14+
}
15+
}
16+
17+
// Reverse each string, sort, flip them back
18+
for(auto& i : v) {
19+
reverse(i.begin(), i.end());
20+
}
21+
sort(v.begin(), v.end());
22+
for(auto& i : v) {
23+
reverse(i.begin(), i.end());
24+
}
25+
26+
// Pad all strings with spaces
27+
for(auto& i : v) {
28+
string temp;
29+
temp.resize(maxlen - i.length(), ' ');
30+
temp += i;
31+
swap(i, temp);
32+
}
33+
34+
// Print the strings
35+
for(auto i : v) {
36+
cout << i << endl;
37+
}
38+
}
39+
40+
int main() {
41+
string s;
42+
vector<string> v;
43+
while(getline(cin, s)) {
44+
if(s == "") {
45+
process(v);
46+
47+
cout << endl;
48+
v.clear();
49+
continue;
50+
}
51+
52+
v.push_back(s);
53+
}
54+
process(v);
55+
}

‎OpenKattis/fbiuniversal/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<img src="problem.png" />

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /