Moved kattis from Uni repo
This commit is contained in:
parent
28a6b807a3
commit
aaa2c123b8
2
kattis/.gitignore
vendored
Normal file
2
kattis/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*.dll/
|
||||
vgcore*
|
5
kattis/.vscode/settings.json
vendored
Normal file
5
kattis/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"stdlib.h": "c"
|
||||
}
|
||||
}
|
28
kattis/.vscode/tasks.json
vendored
Normal file
28
kattis/.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: gcc build active file",
|
||||
"command": "/sbin/gcc",
|
||||
"args": [
|
||||
"-fdiagnostics-color=always",
|
||||
"-g",
|
||||
"${file}",
|
||||
"-o",
|
||||
"${fileDirname}/${fileBasenameNoExtension}"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "Task generated by Debugger."
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
2
kattis/README.md
Normal file
2
kattis/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
# New automatic problem getter
|
||||
## Deleted 52 problems
|
76
kattis/kattis.py
Normal file
76
kattis/kattis.py
Normal file
@ -0,0 +1,76 @@
|
||||
from autokattis import Kattis
|
||||
import argparse
|
||||
from os import system
|
||||
from requests import get
|
||||
from bs4 import BeautifulSoup
|
||||
from datetime import datetime
|
||||
|
||||
def prepare_problem(problem):
|
||||
system('firefox ' + problem['link'])
|
||||
name = " "
|
||||
try:
|
||||
name = problem['pid']
|
||||
except:
|
||||
name = problem['name']
|
||||
|
||||
# system('mkdir problems/' + datetime.now.strftime("%d_%m_%y") + "/" name)
|
||||
|
||||
# TODO: Add inputs
|
||||
r = get(problem['link'])
|
||||
# tables = soup.find_all('table')
|
||||
# soup = BeautifulSoup(r.text, 'html.parser')
|
||||
# for table in tables:
|
||||
# with open("problems/" + problem['pid'] + "/"+ str(count) + ".in", "w") as f:
|
||||
# f.write(table[0].text)
|
||||
# print(table.text)
|
||||
|
||||
def find_user(ranklist:dict) -> int:
|
||||
for i in ranklist:
|
||||
if i['username'] == 'confestim':
|
||||
return i['rank']
|
||||
return -1
|
||||
|
||||
parser = argparse.ArgumentParser(description='Kattis submission tool')
|
||||
parser.add_argument('-p', metavar='problem', type=str, help='problem name')
|
||||
parser.add_argument('-pl', action='store_true', default=False, help='plot problem')
|
||||
parser.add_argument('-s', action='store_true', default=False, help='suggest problem')
|
||||
parser.add_argument('-r', action='store_true', default=False, help='Show ranklist')
|
||||
parser.add_argument('-u', action="store_true", default=False, help="ShowStarted, but Unsolved")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
kt = Kattis('confestim', 'not my actual password lol', )
|
||||
problem = args.p
|
||||
plot = args.pl
|
||||
suggest = args.s
|
||||
unsolved = args.u
|
||||
|
||||
if args.r:
|
||||
uni = find_user(kt.ranklist(university='University of Groningen'))
|
||||
country = find_user(kt.ranklist(country='Bulgaria'))
|
||||
print("🎓:" + str(uni) + ", 🤻 :" + str(country))
|
||||
if plot:
|
||||
print(kt.plot_problems(show_partial=False))
|
||||
|
||||
if suggest:
|
||||
for i in kt.suggest():
|
||||
prepare_problem(i)
|
||||
|
||||
def stars(problem):
|
||||
return problem["difficulty"]
|
||||
|
||||
if unsolved:
|
||||
problems = kt.problems(show_solved=False, show_tried=True)
|
||||
problems.sort(key=stars)
|
||||
print(str(len(problems)) + " problems unsolved.")
|
||||
for problem in problems:
|
||||
print(f"✱ {problem['name']} {problem['difficulty']}✪")
|
||||
yn = input("Do you want to open them in browser?(Y/n)")
|
||||
if (yn == 'n' or yn == 'N'):
|
||||
pass
|
||||
else:
|
||||
for problem in problems:
|
||||
prepare_problem(problem)
|
||||
|
||||
elif problem:
|
||||
print(kt.problem(problem))
|
23
kattis/problems/01_11_23/filip/main.c
Normal file
23
kattis/problems/01_11_23/filip/main.c
Normal file
@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
int reverse(int n) {
|
||||
int reversed = 0;
|
||||
while (n > 0) {
|
||||
reversed = reversed * 10 + n % 10;
|
||||
n /= 10;
|
||||
}
|
||||
return reversed;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int a, b;
|
||||
scanf("%d %d", &a, &b);
|
||||
a = reverse(a);
|
||||
b = reverse(b);
|
||||
|
||||
printf("%d\n", a > b ? a : b);
|
||||
return 0;
|
||||
}
|
34
kattis/problems/01_11_23/filip/main.c.orig
Normal file
34
kattis/problems/01_11_23/filip/main.c.orig
Normal file
@ -0,0 +1,34 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
int powerOfTen(int a) {
|
||||
int result = 10;
|
||||
for (int i=0; i<a; i++) {
|
||||
result *= 10;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void findLarger(int a, int b) {
|
||||
for (int i=0; i<3; i++) {
|
||||
if (a%10 > b%10) {
|
||||
printf("%d", a%10);
|
||||
} else {
|
||||
printf("%d", b%10);
|
||||
}
|
||||
a /= 10;
|
||||
b /=10;
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
}
|
||||
|
||||
// FIX: Reverse number
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int a, b;
|
||||
scanf("%d %d", &a, &b);
|
||||
findLarger(a, b);
|
||||
return 0;
|
||||
}
|
BIN
kattis/problems/01_11_23/filip/program
Executable file
BIN
kattis/problems/01_11_23/filip/program
Executable file
Binary file not shown.
2
kattis/problems/01_11_23/gcvwr/1.in
Normal file
2
kattis/problems/01_11_23/gcvwr/1.in
Normal file
@ -0,0 +1,2 @@
|
||||
12000 3000 5
|
||||
400 25 200 80 500
|
2
kattis/problems/01_11_23/gcvwr/2.in
Normal file
2
kattis/problems/01_11_23/gcvwr/2.in
Normal file
@ -0,0 +1,2 @@
|
||||
10000 4000 7
|
||||
110 10 20 10 5 3 5
|
16
kattis/problems/01_11_23/gcvwr/main.c
Normal file
16
kattis/problems/01_11_23/gcvwr/main.c
Normal file
@ -0,0 +1,16 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int g, t, n;
|
||||
scanf("%d %d %d", &g, &t, &n);
|
||||
int sum = 0;
|
||||
for (int i=0; i<n; i++) {
|
||||
int a;
|
||||
scanf("%d", &a);
|
||||
sum += a;
|
||||
}
|
||||
int lol = (g-t) * 9/10;
|
||||
printf("%d\n", lol-sum);
|
||||
return 0;
|
||||
}
|
11
kattis/problems/01_11_23/gcvwr/main.c.orig
Normal file
11
kattis/problems/01_11_23/gcvwr/main.c.orig
Normal file
@ -0,0 +1,11 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int g, t, n;
|
||||
scanf("%d %d %d", &g, &t, &n);
|
||||
int sum = 0;
|
||||
for (int i=0; i<n; i++) sum++;
|
||||
printf("%d\n", g-t-sum);
|
||||
return 0;
|
||||
}
|
BIN
kattis/problems/01_11_23/gcvwr/program
Executable file
BIN
kattis/problems/01_11_23/gcvwr/program
Executable file
Binary file not shown.
9
kattis/problems/01_11_23/julmust/main.c
Normal file
9
kattis/problems/01_11_23/julmust/main.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
1
kattis/problems/01_11_23/keystrokes/1.in
Normal file
1
kattis/problems/01_11_23/keystrokes/1.in
Normal file
@ -0,0 +1 @@
|
||||
iLnLnLeLb
|
1
kattis/problems/01_11_23/keystrokes/2.in
Normal file
1
kattis/problems/01_11_23/keystrokes/2.in
Normal file
@ -0,0 +1 @@
|
||||
arnarLLLBBun
|
1
kattis/problems/01_11_23/keystrokes/3.in
Normal file
1
kattis/problems/01_11_23/keystrokes/3.in
Normal file
@ -0,0 +1 @@
|
||||
password123
|
60
kattis/problems/01_11_23/keystrokes/main.c
Normal file
60
kattis/problems/01_11_23/keystrokes/main.c
Normal file
@ -0,0 +1,60 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define MAX 1000000
|
||||
|
||||
int transform(char *src, int len, char *dst) {
|
||||
// Traverse the string
|
||||
int i = len;
|
||||
int j = 0;
|
||||
while (i > 0) {
|
||||
// printf("%c\n", src[i]);
|
||||
// If we encounter a backspace, we need to remove the last character
|
||||
// from the destination string
|
||||
if (src[i] == 'B') {
|
||||
if (j > 0) {
|
||||
j--;
|
||||
}
|
||||
} else if (src[i] == 'L') {
|
||||
// If we encounter a left button, we have to move back once
|
||||
if (j > 0) {
|
||||
j--;
|
||||
}
|
||||
} else if (src[i] == 'R') {
|
||||
// If we encounter a right button, we have to move forward once
|
||||
if (j < len) {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
// Otherwise, we add the character to the destination string
|
||||
dst[j] = src[i];
|
||||
j++;
|
||||
}
|
||||
i--;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
void printStr(char *s, int len) {
|
||||
for (int i = 0; i < len; ++i) {
|
||||
printf("%c", s[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
char s[MAX];
|
||||
scanf("%s", s);
|
||||
int len = strlen(s);
|
||||
printf("%d\n", len);
|
||||
char corrected[MAX];
|
||||
|
||||
int newLen = transform(s, len, corrected);
|
||||
printf("%d\n", newLen);
|
||||
printStr(corrected, newLen);
|
||||
return 0;
|
||||
}
|
58
kattis/problems/01_11_23/keystrokes/main.c.orig
Normal file
58
kattis/problems/01_11_23/keystrokes/main.c.orig
Normal file
@ -0,0 +1,58 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define MAX 1000000
|
||||
|
||||
int transform(char *src, int len, char *dst) {
|
||||
// Traverse the string
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
while (i < len) {
|
||||
// If we encounter a backspace, we need to remove the last character
|
||||
// from the destination string
|
||||
if (src[i] == 'B') {
|
||||
if (j > 0) {
|
||||
j--;
|
||||
}
|
||||
} else if (src[i] == 'L') {
|
||||
// If we encounter a left button, we have to move back once
|
||||
if (j > 0) {
|
||||
j--;
|
||||
}
|
||||
} else if (src[i] == 'R') {
|
||||
// If we encounter a right button, we have to move forward once
|
||||
if (j < len) {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
// Otherwise, we add the character to the destination string
|
||||
dst[j] = src[i];
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
void printStr(char *s, int len) {
|
||||
for (int i = 0; i < len; ++i) {
|
||||
printf("%c", s[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
char s[MAX];
|
||||
scanf("%s", s);
|
||||
int len = strlen(s);
|
||||
char corrected[MAX];
|
||||
|
||||
int newLen = transform(s, len, corrected);
|
||||
printf("%d\n", newLen);
|
||||
printStr(corrected, newLen);
|
||||
return 0;
|
||||
}
|
22
kattis/problems/01_11_23/keystrokes/main.py
Normal file
22
kattis/problems/01_11_23/keystrokes/main.py
Normal file
@ -0,0 +1,22 @@
|
||||
string = input()
|
||||
string_list = []
|
||||
cursor = 0
|
||||
for char in string:
|
||||
# If 'L' found in string, we move the cursor to the left
|
||||
if char == 'L':
|
||||
if cursor > 0:
|
||||
cursor -= 1
|
||||
# If 'R' found in string, we move the cursor to the right
|
||||
elif char == 'R':
|
||||
if cursor < len(string):
|
||||
cursor += 1
|
||||
# If 'B' found in string, we delete the character to the left of the cursor
|
||||
elif char == 'B':
|
||||
del string_list[cursor - 1]
|
||||
cursor -= 1
|
||||
# If any other character found in string, we insert it to the left of the cursor
|
||||
else:
|
||||
string_list.insert(cursor, char)
|
||||
cursor += 1
|
||||
# Print only the new string, without the initial one
|
||||
print(''.join(string_list))
|
BIN
kattis/problems/01_11_23/keystrokes/program
Executable file
BIN
kattis/problems/01_11_23/keystrokes/program
Executable file
Binary file not shown.
13
kattis/problems/01_11_23/pieceofcake/main.c
Normal file
13
kattis/problems/01_11_23/pieceofcake/main.c
Normal file
@ -0,0 +1,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n, h, v;
|
||||
scanf("%d %d %d", &n, &h, &v);
|
||||
|
||||
int max_h = h > n - h ? h : n - h;
|
||||
int max_v = v > n - v ? v : n - v;
|
||||
|
||||
printf("%d\n", max_h * max_v * 4);
|
||||
return 0;
|
||||
}
|
20
kattis/problems/01_11_23/ratingproblems/main.c
Normal file
20
kattis/problems/01_11_23/ratingproblems/main.c
Normal file
@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n, k;
|
||||
scanf("%d %d", &n, &k);
|
||||
int sum = 0;
|
||||
for (int i = 0; i < k; ++i) {
|
||||
int x;
|
||||
scanf("%d", &x);
|
||||
sum += x;
|
||||
}
|
||||
|
||||
int min = sum - (n - k) * 3;
|
||||
int max = sum + (n - k) * 3;
|
||||
printf("%.6f %.6f\n", min / (double)n, max / (double)n);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
25
kattis/problems/01_11_23/refrigerator/main.c
Normal file
25
kattis/problems/01_11_23/refrigerator/main.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int pa, ka, pb, kb, n;
|
||||
scanf("%d %d %d %d %d", &pa, &ka, &pb, &kb, &n);
|
||||
|
||||
int tripsA = 0, tripsB = 0;
|
||||
int totalCost = 0;
|
||||
int costA = pa/ka;
|
||||
int costB = pb/kb;
|
||||
|
||||
while (n > 0) {
|
||||
if (costA < costB && ka < n) {
|
||||
tripsA++;
|
||||
totalCost += pa;
|
||||
} else {
|
||||
tripsB++;
|
||||
totalCost += pb;
|
||||
}
|
||||
n--;
|
||||
}
|
||||
printf("%d %d %d\n", tripsA, tripsB, totalCost);
|
||||
return 0;
|
||||
}
|
26
kattis/problems/01_11_23/refrigerator/main.c.orig
Normal file
26
kattis/problems/01_11_23/refrigerator/main.c.orig
Normal file
@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int pa, ka, pb, kb, n;
|
||||
scanf("%d %d %d %d %d", &pa, &ka, &pb, &kb, &n);
|
||||
|
||||
int tripsA = 0, tripsB = 0;
|
||||
int totalCost = 0;
|
||||
int costA = pa/ka;
|
||||
int costB = pb/kb;
|
||||
|
||||
|
||||
while (n > 0) {
|
||||
if (pa < pb && ka < n) {
|
||||
tripsA++;
|
||||
totalCost += pa;
|
||||
} else {
|
||||
tripsB++;
|
||||
totalCost += pb;
|
||||
}
|
||||
n--;
|
||||
}
|
||||
printf("%d %d %d\n", tripsA, tripsB, pa+pb);
|
||||
return 0;
|
||||
}
|
BIN
kattis/problems/01_11_23/refrigerator/program
Executable file
BIN
kattis/problems/01_11_23/refrigerator/program
Executable file
Binary file not shown.
40
kattis/problems/01_11_23/weakvertices/main.c
Normal file
40
kattis/problems/01_11_23/weakvertices/main.c
Normal file
@ -0,0 +1,40 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define MAX 21
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n;
|
||||
scanf("%d", &n);
|
||||
int matrix[MAX][MAX];
|
||||
int i, j, k;
|
||||
while (n != -1) {
|
||||
for (i = 0; i < n; i++) {
|
||||
for (j = 0; j < n; j++) {
|
||||
scanf("%d", &matrix[i][j]);
|
||||
}
|
||||
}
|
||||
int weak[MAX];
|
||||
for (i = 0; i < n; i++) {
|
||||
weak[i] = 1;
|
||||
}
|
||||
for (i = 0; i < n; i++) {
|
||||
for (j = 0; j < n; j++) {
|
||||
for (k = 0; k < n; k++) {
|
||||
if (matrix[i][j] && matrix[j][k] && matrix[k][i]) {
|
||||
weak[i] = 0;
|
||||
weak[j] = 0;
|
||||
weak[k] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i = 0; i < n; i++) {
|
||||
if (weak[i]) {
|
||||
printf("%d ", i);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
scanf("%d", &n);
|
||||
}
|
||||
}
|
11
kattis/problems/01_11_23/whichisgreater/main.c
Normal file
11
kattis/problems/01_11_23/whichisgreater/main.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define MIN(x,y) x>y ? 1 : 0
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int a, b;
|
||||
scanf("%d %d", &a, &b);
|
||||
printf("%d\n", MIN(a, b));
|
||||
return 0;
|
||||
}
|
11
kattis/problems/01_11_23/whichisgreater/main.c.orig
Normal file
11
kattis/problems/01_11_23/whichisgreater/main.c.orig
Normal file
@ -0,0 +1,11 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define MIN(x,y) x>y ? 1 : 0
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int a,b;
|
||||
scanf("%d %d");
|
||||
printf("%d\n", MIN(a,b));
|
||||
return 0;
|
||||
}
|
BIN
kattis/problems/01_11_23/whichisgreater/program
Executable file
BIN
kattis/problems/01_11_23/whichisgreater/program
Executable file
Binary file not shown.
1
kattis/problems/02_11_23/cprnummer/1.in
Normal file
1
kattis/problems/02_11_23/cprnummer/1.in
Normal file
@ -0,0 +1 @@
|
||||
070761-4285
|
1
kattis/problems/02_11_23/cprnummer/2.in
Normal file
1
kattis/problems/02_11_23/cprnummer/2.in
Normal file
@ -0,0 +1 @@
|
||||
051002-4321
|
1
kattis/problems/02_11_23/cprnummer/3.in
Normal file
1
kattis/problems/02_11_23/cprnummer/3.in
Normal file
@ -0,0 +1 @@
|
||||
310111-0469
|
28
kattis/problems/02_11_23/cprnummer/main.c
Normal file
28
kattis/problems/02_11_23/cprnummer/main.c
Normal file
@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// Do with scanf
|
||||
|
||||
int values[10] = {4, 3, 2, 7, 6, 5, 4, 3, 2, 1};
|
||||
int sum = 0;
|
||||
for (int i=0; i<10; i++) {
|
||||
char s;
|
||||
if ((s = getchar()) == '-') {
|
||||
i--;
|
||||
continue;
|
||||
} else {
|
||||
sum += (s - '0') * values[i];
|
||||
}
|
||||
|
||||
}
|
||||
printf("Sum: %d\n", sum);
|
||||
|
||||
if (sum % 11 == 0) {
|
||||
printf("1\n");
|
||||
} else {
|
||||
printf("0\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
28
kattis/problems/02_11_23/cprnummer/main.c.orig
Normal file
28
kattis/problems/02_11_23/cprnummer/main.c.orig
Normal file
@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// Do with scanf
|
||||
|
||||
int values[10] = {4, 3, 2, 7, 6, 5, 4, 3, 2, 1};
|
||||
int sum = 0;
|
||||
for (int i=0; i<10; i++) {
|
||||
char s;
|
||||
if ((s = getchar()) == '-') {
|
||||
i--;
|
||||
continue;
|
||||
} else {
|
||||
sum += (s - '0') * values[i];
|
||||
}
|
||||
|
||||
}
|
||||
printf("Sum: %d\n", sum);
|
||||
|
||||
if (sum % 11 == 0) {
|
||||
printf("1\n");
|
||||
} else {
|
||||
printf("0\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
11
kattis/problems/02_11_23/cprnummer/main.py
Normal file
11
kattis/problems/02_11_23/cprnummer/main.py
Normal file
@ -0,0 +1,11 @@
|
||||
lol = input().replace("-", "")
|
||||
values = [4, 3, 2, 7, 6, 5, 4, 3, 2, 1];
|
||||
|
||||
sum = 0
|
||||
for i in range(10):
|
||||
sum += int(lol[i]) * values[i]
|
||||
|
||||
if sum % 11 == 0:
|
||||
print(1)
|
||||
else:
|
||||
print(0)
|
BIN
kattis/problems/02_11_23/cprnummer/program
Executable file
BIN
kattis/problems/02_11_23/cprnummer/program
Executable file
Binary file not shown.
7
kattis/problems/02_11_23/horror/1.in
Normal file
7
kattis/problems/02_11_23/horror/1.in
Normal file
@ -0,0 +1,7 @@
|
||||
6 3 5
|
||||
0 5 2
|
||||
0 1
|
||||
1 2
|
||||
4 5
|
||||
3 5
|
||||
0 2
|
5
kattis/problems/02_11_23/horror/2.in
Normal file
5
kattis/problems/02_11_23/horror/2.in
Normal file
@ -0,0 +1,5 @@
|
||||
6 2 3
|
||||
5 2
|
||||
0 5
|
||||
0 1
|
||||
3 4
|
48
kattis/problems/02_11_23/horror/main.c
Normal file
48
kattis/problems/02_11_23/horror/main.c
Normal file
@ -0,0 +1,48 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void printArr(int *arr, int n) {
|
||||
for (int i=0; i<n; i++) {
|
||||
printf("%d ", arr[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void fillArr(int *arr, int n, int val) {
|
||||
for (int i=0; i<n; i++) {
|
||||
arr[i] = val;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int n, h, l;
|
||||
scanf("%d %d %d", &n, &h, &l);
|
||||
|
||||
int ids[1000];
|
||||
for (int i=0; i<h; i++) {
|
||||
scanf("%d", &ids[i]);
|
||||
}
|
||||
printArr(ids, h);
|
||||
|
||||
int freq[1001];
|
||||
fillArr(freq, 1000, -1);
|
||||
|
||||
for (int i=0; i<l; i++) {
|
||||
int a, b;
|
||||
scanf("%d %d", &a, &b);
|
||||
int old_a = freq[a];
|
||||
if (freq[a] == -1) {
|
||||
freq[a] = 0;
|
||||
}
|
||||
if (freq[b] == -1) {
|
||||
freq[b] = 0;
|
||||
}
|
||||
freq[a] += freq[b] + 1;
|
||||
freq[b] += old_a + 1;
|
||||
}
|
||||
|
||||
printArr(freq, n+1);
|
||||
|
||||
return 0;
|
||||
}
|
34
kattis/problems/02_11_23/horror/main.c.orig
Normal file
34
kattis/problems/02_11_23/horror/main.c.orig
Normal file
@ -0,0 +1,34 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void printArr(int *arr, int n) {
|
||||
for (int i=0; i<n; i++) {
|
||||
printf("%d ", arr[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int n, h, l;
|
||||
scanf("%d %d %d", &n, &h, &l);
|
||||
|
||||
int ids[1000];
|
||||
for (int i=0; i<h; i++) {
|
||||
scanf("%d", &ids[i]);
|
||||
}
|
||||
|
||||
int freq[1001];
|
||||
for (int i=0; i<l; i++) {
|
||||
int a,b;
|
||||
scanf("%d %d", &a, &b);
|
||||
int old_a = freq[a];
|
||||
freq[a] += freq[b] + 1;
|
||||
freq[b] += old_a + 1;
|
||||
}
|
||||
|
||||
printArr(freq, n+1);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
4
kattis/problems/02_11_23/horror/main.py
Normal file
4
kattis/problems/02_11_23/horror/main.py
Normal file
@ -0,0 +1,4 @@
|
||||
n, h, l = map(int, input().split(" "))
|
||||
horrors = list(map(int, input().split(" ")))
|
||||
|
||||
ids = [x for x in range(h)]
|
BIN
kattis/problems/02_11_23/horror/program
Executable file
BIN
kattis/problems/02_11_23/horror/program
Executable file
Binary file not shown.
26
kattis/problems/02_11_23/knotknowledge/main.c
Normal file
26
kattis/problems/02_11_23/knotknowledge/main.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n;
|
||||
scanf("%d", &n);
|
||||
|
||||
int sum = 0;
|
||||
|
||||
for (int i=0; i<n; i++) {
|
||||
int temp;
|
||||
scanf("%d", &temp);
|
||||
sum += temp;
|
||||
}
|
||||
|
||||
int otherSum = 0;
|
||||
for (int i=0; i<n-1; i++) {
|
||||
int temp;
|
||||
scanf("%d", &temp);
|
||||
otherSum += temp;
|
||||
}
|
||||
|
||||
printf("%d\n", sum - otherSum);
|
||||
|
||||
return 0;
|
||||
}
|
31
kattis/problems/02_11_23/shopaholic/main.c
Normal file
31
kattis/problems/02_11_23/shopaholic/main.c
Normal file
@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Compare in order to sort from largest to smallest
|
||||
int compare(const void *a, const void *b) {
|
||||
return *(int *)b - *(int *)a;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n;
|
||||
scanf("%d", &n);
|
||||
|
||||
int prices[200001];
|
||||
|
||||
for (int i=0; i<n; i++) {
|
||||
scanf("%d", &prices[i]);
|
||||
}
|
||||
|
||||
long long sum = 0;
|
||||
|
||||
qsort(prices, n, sizeof(int), compare);
|
||||
for (int i=2; i<n; i+=3) {
|
||||
sum += prices[i];
|
||||
}
|
||||
|
||||
printf("%lld\n", sum);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
30
kattis/problems/02_11_23/shopaholic/main.c.orig
Normal file
30
kattis/problems/02_11_23/shopaholic/main.c.orig
Normal file
@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Compare in order to sort from largest to smallest
|
||||
int compare(const void *a, const void *b) {
|
||||
return *(int*)b - *(int*)a;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n;
|
||||
scanf("%d", &n);
|
||||
|
||||
int *prices = malloc(sizeof(int) * n);
|
||||
|
||||
for (int i=0; i<n; i++) {
|
||||
scanf("%d", &prices[i]);
|
||||
}
|
||||
|
||||
int sum = 0;
|
||||
|
||||
qsort(prices, n, sizeof(int), compare);
|
||||
for (int i=2; i<n; i+=3) {
|
||||
sum += prices[i];
|
||||
}
|
||||
|
||||
printf("%d\n", sum);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
BIN
kattis/problems/02_11_23/shopaholic/program
Executable file
BIN
kattis/problems/02_11_23/shopaholic/program
Executable file
Binary file not shown.
9
kattis/problems/02_11_23/trianglearea/main.c
Normal file
9
kattis/problems/02_11_23/trianglearea/main.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int h, b;
|
||||
scanf("%d %d", &h, &b);
|
||||
|
||||
printf("%f\n", (h*b)/2.0);
|
||||
}
|
BIN
kattis/problems/02_11_23/trianglearea/program
Executable file
BIN
kattis/problems/02_11_23/trianglearea/program
Executable file
Binary file not shown.
11
kattis/problems/02_11_23/universityzoning/main.c
Normal file
11
kattis/problems/02_11_23/universityzoning/main.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int r, c, s, f, t, g;
|
||||
scanf("%d %d %d %d %d %d", &r, &c, &s, &f, &t, &g);
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
16
kattis/problems/03_11_23/countthevowels/main.c
Normal file
16
kattis/problems/03_11_23/countthevowels/main.c
Normal file
@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char c;
|
||||
int vowels = 0;
|
||||
while ((c=getchar()) != '\n') {
|
||||
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' ||
|
||||
c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U') {
|
||||
vowels++;
|
||||
}
|
||||
}
|
||||
|
||||
printf("%d\n", vowels);
|
||||
return 0;
|
||||
}
|
24
kattis/problems/03_11_23/eyeofsauron/main.c
Normal file
24
kattis/problems/03_11_23/eyeofsauron/main.c
Normal file
@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
char c;
|
||||
int count = 0;
|
||||
int firstSide = 0;
|
||||
while ((c=getchar()) != '\n') {
|
||||
if (c == '(') {
|
||||
firstSide = count;
|
||||
count = 0;
|
||||
}
|
||||
if (c == '|') {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count == firstSide) {
|
||||
printf("correct\n");
|
||||
} else {
|
||||
printf("fix\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
2
kattis/problems/06_11_23/classfieldtrip/1.in
Normal file
2
kattis/problems/06_11_23/classfieldtrip/1.in
Normal file
@ -0,0 +1,2 @@
|
||||
ahjmnoy
|
||||
acijjkll
|
61
kattis/problems/06_11_23/classfieldtrip/main.c
Normal file
61
kattis/problems/06_11_23/classfieldtrip/main.c
Normal file
@ -0,0 +1,61 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// void concatForEach(char *a, char *b, char *target ) {
|
||||
// int lenA = strlen(a);
|
||||
// int lenB = strlen(b);
|
||||
|
||||
// // We use the smaller one
|
||||
// char *using = lenA > lenB ? b : a;
|
||||
// int usingLen = lenA > lenB ? lenB : lenA;
|
||||
|
||||
// int i;
|
||||
// for (i=0; i < usingLen; i+=2) {
|
||||
// target[i] = a[i];
|
||||
// target[i+1] = b[i];
|
||||
// }
|
||||
|
||||
// // Now we use the bigger one
|
||||
// char *new = lenA > lenB ? a : b;
|
||||
// int newLen = lenA > lenB ? lenA : lenB;
|
||||
|
||||
// for (; i < newLen-usingLen; i++) {
|
||||
// target[i] = a[i];
|
||||
// }
|
||||
|
||||
// return;
|
||||
|
||||
// }
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char ann[100];
|
||||
char ben[100];
|
||||
|
||||
scanf("%s", ann);
|
||||
scanf("%s", ben);
|
||||
|
||||
char total[200];
|
||||
|
||||
// Concatenate
|
||||
strcat(total, ann);
|
||||
strcat(total, ben);
|
||||
|
||||
// Alphabetical sort
|
||||
int len = strlen(total);
|
||||
int i, j;
|
||||
for (i=0; i < len; i++) {
|
||||
for (j=0; j < len-i-1; j++) {
|
||||
if (total[j] > total[j+1]) {
|
||||
char temp = total[j];
|
||||
total[j] = total[j+1];
|
||||
total[j+1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0; i < len; i++) {
|
||||
printf("%c", total[i]);
|
||||
}
|
||||
printf("\r\n");
|
||||
return 0;
|
||||
}
|
61
kattis/problems/06_11_23/classfieldtrip/main.c.orig
Normal file
61
kattis/problems/06_11_23/classfieldtrip/main.c.orig
Normal file
@ -0,0 +1,61 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// void concatForEach(char *a, char *b, char *target ) {
|
||||
// int lenA = strlen(a);
|
||||
// int lenB = strlen(b);
|
||||
|
||||
// // We use the smaller one
|
||||
// char *using = lenA > lenB ? b : a;
|
||||
// int usingLen = lenA > lenB ? lenB : lenA;
|
||||
|
||||
// int i;
|
||||
// for (i=0; i < usingLen; i+=2) {
|
||||
// target[i] = a[i];
|
||||
// target[i+1] = b[i];
|
||||
// }
|
||||
|
||||
// // Now we use the bigger one
|
||||
// char *new = lenA > lenB ? a : b;
|
||||
// int newLen = lenA > lenB ? lenA : lenB;
|
||||
|
||||
// for (; i < newLen-usingLen; i++) {
|
||||
// target[i] = a[i];
|
||||
// }
|
||||
|
||||
// return;
|
||||
|
||||
// }
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char ann[100];
|
||||
char ben[100];
|
||||
|
||||
scanf("%s", ann);
|
||||
scanf("%s", ben);
|
||||
|
||||
char total[200];
|
||||
|
||||
// Concatenate
|
||||
strcat(total, ann);
|
||||
strcat(total, ben);
|
||||
|
||||
// Alphabetical sort
|
||||
int len = strlen(total);
|
||||
int i, j;
|
||||
for (i=0; i < len; i++) {
|
||||
for (j=0; j < len-i-1; j++) {
|
||||
if (total[j] > total[j+1]) {
|
||||
char temp = total[j];
|
||||
total[j] = total[j+1];
|
||||
total[j+1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Print
|
||||
printf("%s\n", total);
|
||||
|
||||
return 0;
|
||||
}
|
10
kattis/problems/06_11_23/classfieldtrip/main.py
Normal file
10
kattis/problems/06_11_23/classfieldtrip/main.py
Normal file
@ -0,0 +1,10 @@
|
||||
ann = input()
|
||||
bob = input()
|
||||
|
||||
total = ann + bob
|
||||
sorted_total = sorted(total)
|
||||
|
||||
print("".join(sorted_total))
|
||||
|
||||
|
||||
|
BIN
kattis/problems/06_11_23/classfieldtrip/program
Executable file
BIN
kattis/problems/06_11_23/classfieldtrip/program
Executable file
Binary file not shown.
1
kattis/problems/06_11_23/deadoralive/3.in
Normal file
1
kattis/problems/06_11_23/deadoralive/3.in
Normal file
@ -0,0 +1 @@
|
||||
Firing up EmoticonBot... (: : ( ): :D c:
|
43
kattis/problems/06_11_23/deadoralive/main.c
Normal file
43
kattis/problems/06_11_23/deadoralive/main.c
Normal file
@ -0,0 +1,43 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char c;
|
||||
int smiley = 0;
|
||||
int frowny = 0;
|
||||
int eyes = 0;
|
||||
|
||||
// Would be easier if we stored it but why tf not ig
|
||||
int i = 0;
|
||||
while ((c = getchar()) != '\n') {
|
||||
|
||||
// PROUD OF THIS
|
||||
// ↓↓↓↓↓↓↓↓↓↓↓↓↓
|
||||
if (i - eyes > 1) {
|
||||
eyes = 0;
|
||||
}
|
||||
|
||||
if (c == ':') {
|
||||
eyes = i;
|
||||
}
|
||||
if (c == ')' && eyes ) {
|
||||
smiley++;
|
||||
}
|
||||
if (c == '(' && eyes) {
|
||||
frowny++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (frowny && ! smiley) {
|
||||
printf("undead\n");
|
||||
} else if (smiley && !frowny) {
|
||||
printf("alive\n");
|
||||
} else if (smiley && frowny) {
|
||||
printf("double agent\n");
|
||||
} else {
|
||||
printf("machine\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
kattis/problems/06_11_23/deadoralive/program
Executable file
BIN
kattis/problems/06_11_23/deadoralive/program
Executable file
Binary file not shown.
2
kattis/problems/06_11_23/pokechat/1.in
Normal file
2
kattis/problems/06_11_23/pokechat/1.in
Normal file
@ -0,0 +1,2 @@
|
||||
PpIiKkAaCcHhUu
|
||||
001004006008010012014
|
2
kattis/problems/06_11_23/pokechat/2.in
Normal file
2
kattis/problems/06_11_23/pokechat/2.in
Normal file
@ -0,0 +1,2 @@
|
||||
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .,?!0123456789
|
||||
016009011001053016009011001
|
26
kattis/problems/06_11_23/pokechat/main.c
Normal file
26
kattis/problems/06_11_23/pokechat/main.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char translationKey[256];
|
||||
char c;
|
||||
int i = 0;
|
||||
while ((c = getchar()) != '\n') {
|
||||
translationKey[i] = c;
|
||||
i++;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
int phrase;
|
||||
int check = scanf("%3d", &phrase);
|
||||
if (check != 1) {
|
||||
break;
|
||||
}
|
||||
// printf("%d, %d\n", phrase, check);
|
||||
printf("%c", translationKey[phrase-1]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
26
kattis/problems/06_11_23/pokechat/main.c.orig
Normal file
26
kattis/problems/06_11_23/pokechat/main.c.orig
Normal file
@ -0,0 +1,26 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char translationKey[256];
|
||||
char c;
|
||||
int i = 0;
|
||||
while ((c = getchar()) != '\n') {
|
||||
translationKey[i] = c;
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
while (1) {
|
||||
int phrase;
|
||||
int check = scanf("3%d", &phrase);
|
||||
if (check != 1) {
|
||||
break;
|
||||
}
|
||||
printf("%c\n", translationKey[phrase-1]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
BIN
kattis/problems/06_11_23/pokechat/program
Executable file
BIN
kattis/problems/06_11_23/pokechat/program
Executable file
Binary file not shown.
5
kattis/problems/11_11_23/cutthenegativity/1.in
Normal file
5
kattis/problems/11_11_23/cutthenegativity/1.in
Normal file
@ -0,0 +1,5 @@
|
||||
4
|
||||
-1 1 -1 2
|
||||
9 -1 -1 -1
|
||||
-1 3 -1 4
|
||||
7 1 2 -1
|
36
kattis/problems/11_11_23/cutthenegativity/main.c
Normal file
36
kattis/problems/11_11_23/cutthenegativity/main.c
Normal file
@ -0,0 +1,36 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define MAX 100
|
||||
|
||||
void directFlights(int n, int flights[MAX][MAX]) {
|
||||
for (int i=0; i<n; i++) {
|
||||
for (int j=0; j<n; j++) {
|
||||
if (flights[i][j] != -1) {
|
||||
printf("%d %d %d\n", i+1, j+1, flights[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n;
|
||||
int flights[MAX][MAX];
|
||||
|
||||
scanf("%d", &n);
|
||||
int counter = 0;
|
||||
for (int i=0; i<n; i++) {
|
||||
for (int j=0; j<n; j++) {
|
||||
scanf("%d", &flights[i][j]);
|
||||
if (flights[i][j] != -1) {
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("%d\n", counter);
|
||||
directFlights(n, flights);
|
||||
|
||||
return 0;
|
||||
}
|
47
kattis/problems/11_11_23/cutthenegativity/main.c.orig
Normal file
47
kattis/problems/11_11_23/cutthenegativity/main.c.orig
Normal file
@ -0,0 +1,47 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define MAX 100
|
||||
|
||||
void trip(int i, int j, int flights[MAX][MAX]) {
|
||||
if (flights[i][j] == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%d", flights[i][j]);
|
||||
trip(j, flights[i][j], flights);
|
||||
return;
|
||||
}
|
||||
|
||||
void directFlights(int n, int flights[MAX][MAX]) {
|
||||
for (int i=0; i<n; i++) {
|
||||
int printed = 0;
|
||||
for (int j=0; j<n; j++) {
|
||||
if (flights[i][j] != -1) {
|
||||
if (printed) {
|
||||
printf(" ");
|
||||
}
|
||||
printed = 1;
|
||||
trip(i, j, flights);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n;
|
||||
int flights[MAX][MAX];
|
||||
|
||||
scanf("%d", &n);
|
||||
for (int i=0; i<n; i++) {
|
||||
for (int j=0; j<n; j++) {
|
||||
scanf("%d", &flights[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
directFlights(n, flights);
|
||||
|
||||
return 0;
|
||||
}
|
BIN
kattis/problems/11_11_23/cutthenegativity/program
Executable file
BIN
kattis/problems/11_11_23/cutthenegativity/program
Executable file
Binary file not shown.
2
kattis/problems/11_11_23/ekkidaudi/1.in
Normal file
2
kattis/problems/11_11_23/ekkidaudi/1.in
Normal file
@ -0,0 +1,2 @@
|
||||
ho|lo
|
||||
pe|ve
|
2
kattis/problems/11_11_23/ekkidaudi/2.in
Normal file
2
kattis/problems/11_11_23/ekkidaudi/2.in
Normal file
@ -0,0 +1,2 @@
|
||||
ekki |daudi
|
||||
opna| inni
|
72
kattis/problems/11_11_23/ekkidaudi/main.c
Normal file
72
kattis/problems/11_11_23/ekkidaudi/main.c
Normal file
@ -0,0 +1,72 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define MAX 2100
|
||||
|
||||
int isAlpha(char c) {
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
return 1;
|
||||
}
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void printBefore(char first[MAX], char second[MAX]) {
|
||||
for (int i=0; i<strlen(first); i++) {
|
||||
if (first[i] == '|') {
|
||||
break;
|
||||
}
|
||||
if (isAlpha(first[i])) {
|
||||
printf("%c", first[i]);
|
||||
}
|
||||
}
|
||||
for (int i=0; i<strlen(second); i++) {
|
||||
if (second[i] == '|') {
|
||||
break;
|
||||
}
|
||||
if (isAlpha(second[i])) {
|
||||
printf("%c", second[i]);
|
||||
}
|
||||
}
|
||||
printf(" ");
|
||||
}
|
||||
|
||||
void printAfter(char first[MAX], char second[MAX]) {
|
||||
int pipeFound = 0;
|
||||
for (int i=0; i<strlen(first); i++) {
|
||||
if (pipeFound && isAlpha(first[i])) {
|
||||
printf("%c", first[i]);
|
||||
}
|
||||
if (first[i] == '|') {
|
||||
pipeFound = 1;
|
||||
}
|
||||
|
||||
}
|
||||
pipeFound = 0;
|
||||
for (int i=0; i<strlen(second); i++) {
|
||||
if (pipeFound && isAlpha(second[i])) {
|
||||
printf("%c", second[i]);
|
||||
}
|
||||
if (second[i] == '|') {
|
||||
pipeFound = 1;
|
||||
}
|
||||
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
char first[MAX];
|
||||
char second[MAX];
|
||||
|
||||
scanf("%s %s", first, second);
|
||||
|
||||
printBefore(first, second);
|
||||
printAfter(first, second);
|
||||
|
||||
return 0;
|
||||
}
|
68
kattis/problems/11_11_23/ekkidaudi/main.c.orig
Normal file
68
kattis/problems/11_11_23/ekkidaudi/main.c.orig
Normal file
@ -0,0 +1,68 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define MAX 2100
|
||||
|
||||
int isAlpha(char c) {
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
return 1;
|
||||
}
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void printBefore(char first[MAX], char second[MAX]) {
|
||||
for (int i=0; i<strlen(first); i++) {
|
||||
if (first[i] == '|') {
|
||||
break;
|
||||
}
|
||||
if (isAlpha(first[i])) printf("%c", first[i]);
|
||||
}
|
||||
for (int i=0; i<strlen(second); i++) {
|
||||
if (second[i] == '|') {
|
||||
break;
|
||||
}
|
||||
if (isAlpha(second[i])) printf("%c", second[i]);
|
||||
}
|
||||
printf(" ");
|
||||
}
|
||||
|
||||
void printAfter(char first[MAX], char second[MAX]) {
|
||||
int pipeFound = 0;
|
||||
for (int i=0; i<strlen(first); i++) {
|
||||
if (pipeFound) {
|
||||
printf("%c", first[i]);
|
||||
}
|
||||
if (first[i] == '|' && isAlpha(first[i])) {
|
||||
pipeFound = 1;
|
||||
}
|
||||
|
||||
}
|
||||
pipeFound = 0;
|
||||
for (int i=0; i<strlen(second); i++) {
|
||||
if (pipeFound) {
|
||||
printf("%c", second[i]);
|
||||
}
|
||||
if (second[i] == '|' && isAlpha(second[i])) {
|
||||
pipeFound = 1;
|
||||
}
|
||||
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
char first[MAX];
|
||||
char second[MAX];
|
||||
|
||||
scanf("%s %s", first, second);
|
||||
|
||||
printBefore(first, second);
|
||||
printAfter(first, second);
|
||||
|
||||
return 0;
|
||||
}
|
4
kattis/problems/11_11_23/ekkidaudi/main.py
Normal file
4
kattis/problems/11_11_23/ekkidaudi/main.py
Normal file
@ -0,0 +1,4 @@
|
||||
first = input().split("|")
|
||||
second = input().split("|")
|
||||
|
||||
print(first[0] + second[0] + " " + first[1] + second[1])
|
BIN
kattis/problems/11_11_23/ekkidaudi/program
Executable file
BIN
kattis/problems/11_11_23/ekkidaudi/program
Executable file
Binary file not shown.
10
kattis/problems/11_11_23/flatbokuveisla/main.c
Normal file
10
kattis/problems/11_11_23/flatbokuveisla/main.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n, m;
|
||||
scanf("%d %d", &n, &m);
|
||||
|
||||
printf("%d\n", n - (n/m)*m );
|
||||
return 0;
|
||||
}
|
18
kattis/problems/11_11_23/internationaldates/main.c
Normal file
18
kattis/problems/11_11_23/internationaldates/main.c
Normal file
@ -0,0 +1,18 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int x,y,z;
|
||||
scanf("%d/%d/%d", &x, &y, &z);
|
||||
|
||||
// EU OR US OR EITHER
|
||||
if (x > 12) {
|
||||
printf("EU\n");
|
||||
} else if (y > 12) {
|
||||
printf("US\n");
|
||||
} else {
|
||||
printf("either\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
32
kattis/problems/11_11_23/milllifaersla/main.c
Normal file
32
kattis/problems/11_11_23/milllifaersla/main.c
Normal file
@ -0,0 +1,32 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct Transaction {
|
||||
int amount;
|
||||
char *service;
|
||||
} Transaction;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
Transaction x, y, z;
|
||||
x.service = "Monnei";
|
||||
y.service = "Fjee";
|
||||
z.service = "Dolladollabilljoll";
|
||||
scanf("%d %d %d", &x.amount, &y.amount, &z.amount);
|
||||
|
||||
// Get min
|
||||
Transaction min = x;
|
||||
if (y.amount < min.amount) {
|
||||
min = y;
|
||||
}
|
||||
if (z.amount < min.amount) {
|
||||
min = z;
|
||||
}
|
||||
|
||||
printf("%s\n", min.service);
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
0
kattis/problems/13_11_23/platforme/main.c
Normal file
0
kattis/problems/13_11_23/platforme/main.c
Normal file
4
kattis/problems/13_11_23/sith/1.in
Normal file
4
kattis/problems/13_11_23/sith/1.in
Normal file
@ -0,0 +1,4 @@
|
||||
Obi-Wan Kenobi
|
||||
69
|
||||
80
|
||||
-11
|
4
kattis/problems/13_11_23/sith/3.in
Normal file
4
kattis/problems/13_11_23/sith/3.in
Normal file
@ -0,0 +1,4 @@
|
||||
Grogu
|
||||
67
|
||||
17
|
||||
50
|
21
kattis/problems/13_11_23/sith/main.c
Normal file
21
kattis/problems/13_11_23/sith/main.c
Normal file
@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int a, b, diff;
|
||||
char c;
|
||||
while ((c=getchar()) != '\n' ) {
|
||||
continue;
|
||||
}
|
||||
scanf("%d %d %d", &a, &b, &diff);
|
||||
|
||||
if (abs(a-b) == diff && a - b != diff) {
|
||||
printf("SITH\n");
|
||||
} else if (a - b == diff && abs(a-b) != diff ) {
|
||||
printf("JEDI\n");
|
||||
} else {
|
||||
printf("VEIT EKKI\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
25
kattis/problems/13_11_23/sith/main.c.orig
Normal file
25
kattis/problems/13_11_23/sith/main.c.orig
Normal file
@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int absolute(int x) {
|
||||
return x < 0 ? -x : x;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int a, b, diff;
|
||||
char c;
|
||||
while ((c=getchar()) != '\n' ) {
|
||||
continue;
|
||||
}
|
||||
scanf("%d %d %d", &a, &b, &diff);
|
||||
|
||||
if (absolute(a-b) == diff) {
|
||||
printf("SITH\n");
|
||||
} else if (a - b == diff && absolute(a-b) != diff) {
|
||||
printf("JEDI\n");
|
||||
} else {
|
||||
printf("VEIT EKKI\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
BIN
kattis/problems/13_11_23/sith/program
Executable file
BIN
kattis/problems/13_11_23/sith/program
Executable file
Binary file not shown.
4
kattis/problems/13_11_23/vefthjonatjon/1.in
Normal file
4
kattis/problems/13_11_23/vefthjonatjon/1.in
Normal file
@ -0,0 +1,4 @@
|
||||
3
|
||||
J N N
|
||||
N J N
|
||||
N N J
|
3
kattis/problems/13_11_23/vefthjonatjon/2.in
Normal file
3
kattis/problems/13_11_23/vefthjonatjon/2.in
Normal file
@ -0,0 +1,3 @@
|
||||
2
|
||||
J J N
|
||||
N N J
|
35
kattis/problems/13_11_23/vefthjonatjon/main.c
Normal file
35
kattis/problems/13_11_23/vefthjonatjon/main.c
Normal file
@ -0,0 +1,35 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int isThere(char c) {
|
||||
if (c == 'J') {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n;
|
||||
scanf("%d", &n);
|
||||
int cpu = 0, memory = 0, disk = 0;
|
||||
|
||||
for (int i=0; i<n; i++) {
|
||||
char c, m, d;
|
||||
scanf("%c %c %c", &c, &m, &d);
|
||||
if (isThere(c)) {
|
||||
cpu++;
|
||||
}
|
||||
if (isThere(m)) {
|
||||
memory++;
|
||||
}
|
||||
if (isThere(d)) {
|
||||
disk++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
printf("%d %d %d\n", cpu, memory, disk);
|
||||
printf("%d\n", cpu+memory+disk/3);
|
||||
|
||||
return 0;
|
||||
}
|
27
kattis/problems/13_11_23/vefthjonatjon/main.c.orig
Normal file
27
kattis/problems/13_11_23/vefthjonatjon/main.c.orig
Normal file
@ -0,0 +1,27 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int isThere(char c) {
|
||||
if (c == 'J') return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n;
|
||||
scanf("%d", &n);
|
||||
int cpu = 0, memory = 0, disk = 0;
|
||||
|
||||
for (int i=0; i<n; i++) {
|
||||
char c, m, d;
|
||||
scanf("%c %c %c", &c, &m, &d);
|
||||
if (isThere(c)) cpu++;
|
||||
if (isThere(m)) memory++;
|
||||
if (isThere(d)) disk++;
|
||||
|
||||
}
|
||||
|
||||
printf("%d %d %d\n", cpu, memory, disk);
|
||||
printf("%d\n", cpu+memory+disk/3);
|
||||
|
||||
return 0;
|
||||
}
|
17
kattis/problems/13_11_23/vefthjonatjon/main.py
Normal file
17
kattis/problems/13_11_23/vefthjonatjon/main.py
Normal file
@ -0,0 +1,17 @@
|
||||
from math import floor
|
||||
|
||||
def increaseList(lst, c,m,d):
|
||||
lst[0] += c
|
||||
lst[1] += m
|
||||
lst[2] += d
|
||||
return lst
|
||||
n = int(input())
|
||||
|
||||
c,m,d = (0,0,0)
|
||||
|
||||
for i in range(n):
|
||||
cmd = [1 if x == "J" else 0 for x in input().split() ]
|
||||
c,m,d = increaseList(cmd, c,m,d)
|
||||
|
||||
|
||||
print(floor((c+m+d)/3))
|
BIN
kattis/problems/13_11_23/vefthjonatjon/program
Executable file
BIN
kattis/problems/13_11_23/vefthjonatjon/program
Executable file
Binary file not shown.
2
kattis/problems/18_11_23/asciikassi/1.in
Normal file
2
kattis/problems/18_11_23/asciikassi/1.in
Normal file
@ -0,0 +1,2 @@
|
||||
1
|
||||
Hannes
|
17
kattis/problems/18_11_23/asciikassi/main.c
Normal file
17
kattis/problems/18_11_23/asciikassi/main.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int a;
|
||||
scanf("%d", &a);
|
||||
char c;
|
||||
int b[100];
|
||||
while ((c = getchar()) != '\n') {
|
||||
if (c >= 'A' && c <= 'Z' && b[c - 'A'] == 0) {
|
||||
printf("%c", c);
|
||||
b[c - 'A'] = 1;
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
BIN
kattis/problems/18_11_23/asciikassi/program
Executable file
BIN
kattis/problems/18_11_23/asciikassi/program
Executable file
Binary file not shown.
3
kattis/problems/18_11_23/umferd/1.in
Normal file
3
kattis/problems/18_11_23/umferd/1.in
Normal file
@ -0,0 +1,3 @@
|
||||
2
|
||||
1
|
||||
.#
|
4
kattis/problems/18_11_23/umferd/2.in
Normal file
4
kattis/problems/18_11_23/umferd/2.in
Normal file
@ -0,0 +1,4 @@
|
||||
4
|
||||
2
|
||||
#.#.
|
||||
.###
|
23
kattis/problems/18_11_23/umferd/main.c
Normal file
23
kattis/problems/18_11_23/umferd/main.c
Normal file
@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int m, n;
|
||||
scanf("%d %d", &m, &n);
|
||||
|
||||
int empty = 0;
|
||||
int filled = 0;
|
||||
|
||||
for (int i = 0; i < m; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
char c = getchar();
|
||||
if (c == '.') {
|
||||
empty++;
|
||||
} else if (c == '#') {
|
||||
filled++;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%d %d\n", empty, filled);
|
||||
return 0;
|
||||
}
|
23
kattis/problems/18_11_23/umferd/main.c.orig
Normal file
23
kattis/problems/18_11_23/umferd/main.c.orig
Normal file
@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int m, n;
|
||||
scanf("%d %d", &m, &n);
|
||||
|
||||
int empty = 0;
|
||||
int filled = 0;
|
||||
|
||||
for (int i = 0; i < m; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
char c = getchar();
|
||||
if (c == '.') {
|
||||
empty++;
|
||||
} else if (c == '#') {
|
||||
filled++;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%d %d\n",empty, filled);
|
||||
return 0;
|
||||
}
|
BIN
kattis/problems/18_11_23/umferd/program
Executable file
BIN
kattis/problems/18_11_23/umferd/program
Executable file
Binary file not shown.
30
kattis/problems/21_11_23/asciikassi/main.c
Normal file
30
kattis/problems/21_11_23/asciikassi/main.c
Normal file
@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void drawLine(int n) {
|
||||
printf("+");
|
||||
for (int i = 0; i < n; i++) {
|
||||
printf("-");
|
||||
}
|
||||
printf("+\n");
|
||||
}
|
||||
|
||||
void drawRect(int n) {
|
||||
drawLine(n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
printf("|");
|
||||
for (int j = 0; j < n; j++) {
|
||||
printf(" ");
|
||||
}
|
||||
printf("|\n");
|
||||
}
|
||||
drawLine(n);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n;
|
||||
scanf("%d", &n);
|
||||
|
||||
drawRect(n);
|
||||
return 0;
|
||||
}
|
45
kattis/problems/21_11_23/asciikassi/main.c.orig
Normal file
45
kattis/problems/21_11_23/asciikassi/main.c.orig
Normal file
@ -0,0 +1,45 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void drawRect(int n) {
|
||||
// Top part
|
||||
for (int i = 0; i <= n; i++) {
|
||||
if (i == 0 || i == n - 1) {
|
||||
printf("+");
|
||||
} else {
|
||||
printf("-");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
// Middle parts
|
||||
for (int i = 0; i < n - 2; i++) {
|
||||
for (int j = 0; j <= n; j++) {
|
||||
if (j == 0 || j == n - 1) {
|
||||
printf("|");
|
||||
} else {
|
||||
printf(" ");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
// Bottom part
|
||||
for (int i = 0; i <= n; i++) {
|
||||
if (i == 0 || i == n - 1) {
|
||||
printf("+");
|
||||
} else {
|
||||
printf("-");
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n;
|
||||
scanf("%d", &n);
|
||||
|
||||
drawRect(n);
|
||||
return 0;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user