Commit 8ecd5fda8de957aacca91e8c42385eb28b60e0fd

Authored by Ronaldo Silva
Committed by Ronaldo
1 parent 17e4d46737
Exists in main

Update project.

Showing 4 changed files with 91 additions and 30 deletions Side-by-side Diff

.idea/Competitive-Programming.iml View file @ 8ecd5fd
1 1 <?xml version="1.0" encoding="UTF-8"?>
2   -<module type="CPP_MODULE" version="4">
3   - <component name="NewModuleRootManager">
4   - <content url="file://$MODULE_DIR$" />
5   - <orderEntry type="inheritedJdk" />
6   - <orderEntry type="sourceFolder" forTests="false" />
7   - </component>
8   -</module>
  2 +<module classpath="CIDR" type="CPP_MODULE" version="4" />
NumberTheoryandCombinatorics/ProjectEuler/SumSquareDifference/SumSquareDifference.cpp View file @ 8ecd5fd
... ... @@ -3,28 +3,7 @@
3 3 // Problem description Link.
4 4 // https://www.hackerrank.com/contests/projecteuler/challenges/euler006/copy-from/1354371634
5 5  
6   -#include <map>
7   -#include <set>
8   -#include <list>
9   -#include <cmath>
10   -#include <ctime>
11   -#include <deque>
12   -#include <queue>
13   -#include <stack>
14   -#include <string>
15   -#include <bitset>
16   -#include <cstdio>
17   -#include <limits>
18   -#include <vector>
19   -#include <climits>
20   -#include <cstring>
21   -#include <cstdlib>
22   -#include <fstream>
23   -#include <numeric>
24   -#include <sstream>
25   -#include <iostream>
26   -#include <algorithm>
27   -#include <unordered_map>
  6 +#include <bits/stdc++.h>
28 7  
29 8 using namespace std;
30 9  
SearchingSortingandBasicDataStructures/InbuiltSorting/Problem5/SimpleTask.cpp View file @ 8ecd5fd
  1 +//
  2 +// Created by ronal on 2/25/2023.
  3 +//
  4 +
  5 +#include <bits/stdc++.h>
  6 +using namespace std;
  7 +
  8 +int Posicion(int queries, vector<tuple<int, int, int>>& VT){
  9 + int first, last, type, posicion;
  10 + int sum_diff_max = 0;
  11 + int sum_diff_currenty = 0;
  12 +
  13 + for(int i = 0; i < queries; i++){
  14 + cin >> first >> last >> type;
  15 + if(i == 0) {
  16 + sum_diff_max = last - first;
  17 + posicion = i;
  18 + }else{
  19 + sum_diff_currenty = last - first;
  20 + if(sum_diff_max < sum_diff_currenty){
  21 + sum_diff_max = sum_diff_currenty;
  22 + sum_diff_currenty = 0;
  23 + posicion = i;
  24 + }
  25 + }
  26 + VT.emplace_back(first, last, type);
  27 + }
  28 + return posicion;
  29 +}
  30 +int main(){
  31 + ios_base::sync_with_stdio(false);
  32 + cin.tie(NULL);
  33 + string S;
  34 + int size, queries;
  35 + vector<tuple<int, int, int>> VT;
  36 + cin >> size >> queries;
  37 + cin.ignore();
  38 + getline(cin, S);
  39 +
  40 + int p = Posicion(queries, VT);
  41 + for(int i = p; i < VT.size(); i++) {
  42 + if ( get<2>(VT[i]) == 1) {
  43 + sort(S.begin() + get<0>(VT[i]) - 1, S.begin() + get<1>(VT[i]));
  44 + } else if (get<2>(VT[i]) == 0) {
  45 + sort(S.begin() + get<0>(VT[i]) - 1, S.begin() + get<1>(VT[i]), greater<>());
  46 + }
  47 + }
  48 +// for(const auto & i : S){
  49 +// cout << i;
  50 +// }
  51 + cout << S;
  52 + return 0;
  53 +}
SearchingSortingandBasicDataStructures/Set/Problem1/Sets.cpp View file @ 8ecd5fd
  1 +//
  2 +// Created by ronal on 2/25/2023.
  3 +// Problem Description Link.
  4 +// https://www.hackerrank.com/challenges/cpp-sets/problem
  5 +
  6 +#include <bits/stdc++.h>
  7 +using namespace std;
  8 +
  9 +
  10 +int main() {
  11 + int Q, y, x;
  12 + set<int> S;
  13 + cin >> Q;
  14 + for(int i = 0; i < Q; i++){
  15 + cin >> y >> x;
  16 + if(y == 1){
  17 + S.insert(x);
  18 + }else if(y == 2){
  19 + S.erase(x);
  20 + }else if(y == 3){
  21 + auto it = S.find(x);
  22 + if(it != S.end()){
  23 + cout << "Yes\n";
  24 + }else{
  25 + cout << "No\n";
  26 + }
  27 + }
  28 + }
  29 + return 0;
  30 +}