Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved 4 problems + Graphs #52

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Algoritms/Olympiada 2023-2024/Anton_and_watermelons.cpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Использование векторов - кринге

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2022 Zener
// Шаблон для олимпиадных задач

#include <bits/stdc++.h>

using namespace std;

void solve();

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);

#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("error.txt", "w", stderr);
freopen("output.txt", "w", stdout);
#endif

int t = 1;
// /*is Single Test case?*/ cin >> t;
while (t--) {
solve();
cout << "\n";
}

cerr << "time taken : " << (float) clock() / CLOCKS_PER_SEC << " secs" << endl;
return 0;
}

void solve() {
long long n, m, d, temp;
cin >> n >> m >> d;
vector<long long> vec_x;
vector<long long> vec_y;
for(int i = 0; i < d; ++i){
cin >> temp;
vec_x.push_back(temp);
cin >> temp;
vec_y.push_back(temp);
}
long long x = vec_x[0], y = vec_y[0];
for(int i = 0; i < d; ++i){
x = min(x, vec_x[i]);
y = min(y, vec_y[i]);
}
cout << x * y << " " << d;
}
46 changes: 46 additions & 0 deletions Algoritms/Olympiada 2023-2024/Colored_cube.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2022 Zener
// Шаблон для олимпиадных задач

#include <bits/stdc++.h>

using namespace std;

void solve();

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);

#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("error.txt", "w", stderr);
freopen("output.txt", "w", stdout);
#endif

int t = 1;
// /*is Single Test case?*/ cin >> t;
while (t--) {
solve();
cout << "\n";
}

cerr << "time taken : " << (float) clock() / CLOCKS_PER_SEC << " secs" << endl;
return 0;
}

void solve() {
int n, f;
cin >> n >> f;
if(f == 0){
cout << (n - 2) * (n - 2);
}
else if(f == 1){
cout << (n - 2) * (n - 2) * 6;
}
else if(f == 2){
cout << (n - 2) * 12;
}
else if(f == 3){
cout << 8;
}
}
45 changes: 45 additions & 0 deletions Algoritms/Olympiada 2023-2024/Triangle_of_sticks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2022 Zener
// Шаблон для олимпиадных задач

#include <bits/stdc++.h>

using namespace std;

void solve();

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);

#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("error.txt", "w", stderr);
freopen("output.txt", "w", stdout);
#endif

int t = 1;
// /*is Single Test case?*/ cin >> t;
while (t--) {
solve();
cout << "\n";
}

cerr << "time taken : " << (float) clock() / CLOCKS_PER_SEC << " secs" << endl;
return 0;
}

void solve() {
long long a, b, c;
cin >> a >> b >> c;
long long x;
x = max(max(a, b), c);
if(a == x){
cout << b + c - a;
}
else if(b == x){
cout << a + c - b;
}
else{
cout << a + b - c;
}
}
45 changes: 45 additions & 0 deletions Algoritms/Olympiada 2023-2024/paid_musical_services.cpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не проходит временное ограничение. Временная сложность большая

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2022 Zener
// Шаблон для олимпиадных задач

#include <bits/stdc++.h>

using namespace std;

void solve();

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);

#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("error.txt", "w", stderr);
freopen("output.txt", "w", stdout);
#endif

int t = 1;
// /*is Single Test case?*/ cin >> t;
while (t--) {
solve();
cout << "\n";
}

cerr << "time taken : " << (float) clock() / CLOCKS_PER_SEC << " secs" << endl;
return 0;
}

void solve() {
long long n, m;
cin >> n >> m;
long long a = 1, d = 1, ans = 0;
while(d <= m){
if((n - 1) * d <= m){
ans += m - (n - 1) * d;
d += 1;
}
else{
d += 1;
}
}
cout << ans;
}
71 changes: 71 additions & 0 deletions Data_Structures/Graph/Graph.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// Created by User on 15.10.2023.
//

#include <bits/stdc++.h>
#include "Graph.h"


int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("error.txt", "w", stderr);
freopen("output.txt", "w", stdout);
#endif

// Пару городов
string msk = "Moscow";
string piter = "Saint Petersburg";
string kzn = "Kazan";
string inno = "Innopolis";
string ekat = "Ekaterinburg";
string vlad = "Vladivostok";
string pskov = "Pskov";

Graph<string> g;

g.add_vertex(msk);
g.add_vertex(piter);
g.add_vertex(kzn);
g.add_vertex(inno);
g.add_vertex(ekat);
g.add_vertex(vlad);
g.add_vertex(pskov);

g.add_edge(msk, piter);
g.add_edge(msk, kzn);
g.add_edge(piter, kzn);
g.add_edge(kzn, inno);
g.add_edge(kzn, ekat);
g.add_edge(ekat, vlad);
g.add_edge(vlad, pskov);
g.add_edge(msk, pskov);

g.edges()[0].length = 400;
g.edges()[1].length = 680;
g.edges()[2].length = 1200;
g.edges()[3].length = 42;
// Просто должно работать "Moscow Piter"
for (string city : g.path(msk, piter)) {
cout << city << " ";
}
cout << "\n";

// Проверка, сможет ли метод вернуть больше одного города. "Moscow Kazan Innopolis"
for (string city : g.path(msk, inno)) {
cout << city << " ";
}
cout << "\n";

// Проверка, сможет ли метод найти путь покороче. Правильный ответ: "Saint Petersburg Moscow Kazan"
for (string city : g.path(piter, kzn)) {
cout << city << " ";
}
cout << "\n";

vector cities = g.path(piter, pskov);
for (string city : cities) {
cout << city << " ";
}
cout << "\n";
}
Loading