Moved kattis from Uni repo
This commit is contained in:
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;
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user