uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
302f0925-fd43-4e85-8f12-93f6bc4cdb22 | developerYHLee/Algorithm | C++/Sliding Window/B2531.cpp | #include <iostream>
#include <queue>
#include <cmath>
using namespace std;
int N, D, K, C, cnt[3001], belt[30000];
void input() {
cin >> N >> D >> K >> C;
for (int i = 0; i < N; i++) cin >> belt[i];
}
void solve() {
queue<int> Q;
int res = 1, temp = 1;
cnt[C]++;
for (int i = N - K; i < N; i++) {
if (!cnt[... | ALGO | 0.999875 | 3.66229 |
1daba2e9-4870-4477-b9ce-d5100878ec4d | Dushi18/data-structures-and-algorithms | 2d arrays/2d_arary.cpp | #include <iostream>
using namespace std;
bool isValid(int arr[][4], int target, int row, int col){
for(int i = 0; i <row; i++){
for(int j = 0; j <col; j++){
if(arr[i][j] == target){
return 1;
}
}
}
return 0;
}
int rowSum(int arr[][4], int row, int col... | ALGO | 0.999598 | 4.279197 |
df2fafb5-7823-4274-a4e3-2f658d0a833b | dgyf/ProjectXYSketch | Supplement/heavy-keeper-project-master/CounterTree/main.cpp | #include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <fstream>
#include "BOBHASH32.h"
#include "params.h"
#include "Counter_Tree.h"
#include <ctime>
using namespace std;
map <string ,int> B,C,Rank;
struct node {string... | ALGO | 0.980853 | 4.118552 |
de60629d-a603-4e52-a3e9-84a2eb011bd9 | mkp0/CP | CodeForce/A - Avoiding Zero.cpp | #include <bits/stdc++.h>
#define ll long long
#define pi (3.141592653589)
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define mp make_pair
#define S second
#define loop(i, a, b, c) for ... | ALGO | 0.999655 | 4.291444 |
67965bb6-49c2-4c4f-a0f0-b9287496d094 | Priyanshu88/DSA-Sheet-by-Arsh-Goyal | DSA Practice Sheet/Mathematical/Power of Two/main.cpp | class Solution {
public:
// if n is equal to 0 return false
// taking modulo and dividing with 2 for every n
// if n is equal to 1 at last then return true
bool isPowerOfTwo(int n) {
if(n == 0) return false;
while(n % 2 == 0) n /= 2;
return n == 1;
}
};
// T.C. :O(log n)
... | ALGO | 0.999337 | 6.37348 |
77b58d4b-e45e-4ebb-ab53-8c5c6106c514 | mejibyte/live-archive | 3978 - Obfuscation/3978.cpp | /*
Accepted.
*/
#include <deque>
#include <algorithm>
#include <iterator>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
using namespace std;
#define V(x) copy(x.begin(), x.end(), ostream_iterator<... | ALGO | 0.999518 | 3.806146 |
6606a6c6-11e9-464d-bab1-8c91b8fefd90 | devkade/Algorithm | Implement/11653_Factorization.cpp | #include <iostream>
using namespace std;
bool is_primeNum(int n);
int main()
{
int N;
cin >> N;
for(int i=2; i*i<=N; i++)
{
if(is_primeNum(i))
{
while(N%i==0)
{
cout << i << endl;
N = N/i;
}
}
}
if((N!=0)&&(N!=1))
cout << N << endl;
return 0;
}
bool is_primeNum(int n)
{
int i = 2;... | ALGO | 0.999989 | 3.9079 |
b55008e0-9742-4206-b332-9f7caf9f7775 | Aman18111625/LeetCode-Solutions | 814-binary-tree-pruning/814-binary-tree-pruning.cpp | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), l... | ALGO | 0.999873 | 6.106349 |
6c3cf75a-7abd-4bee-83ac-edc8a2b74345 | YeongjuJeong/BOJ | 20000-25000/23235.cpp | // 23235 The fastes Sorting Algorithm In The World
#include <iostream>
#include <string>
using namespace std;
int main() {
int t = 1;
while (1){
int n; cin >> n;
if (!n) break;
int x;
for (int i = 0; i < n; i++) {
cin >> x;
}
cout << "Case " << t++ <... | ALGO | 0.99873 | 5.050046 |
92ec8cfc-3bf3-46c7-a484-e83136db066f | Henrik-Knierim/hpc_esc_401 | exercise_session_12/poisson_solver_MPI/mpi_module.cpp | #include <mpi.h>
#include <stdio.h>
#include "init.h"
int start_MPI(int* my_rank, int* size){
printf("Setting MPI environment\n");
MPI_Init(NULL,NULL);
MPI_Comm_size(MPI_COMM_WORLD,size);
MPI_Comm_rank(MPI_COMM_WORLD,my_rank);
return 0;
}
int close_MPI(){
MPI_Finalize();
return 0;
}
int mpi_get_domain(int nx... | ALGO | 0.999656 | 4.731215 |
d6960d69-3ad8-475a-93ed-15cb8ede1a29 | hjiang13/LLMs-in-IR | POJ-104/96/886.cpp | #include <iostream>
using namespace std;
int main()
{
char str[101];
int answer[101];
memset(answer,0,sizeof(answer));
int p,q,flag=0,j,i,k;
cin>>str;
i=0;
for(j=0; j<strlen(str); j++)
{
p=0;
for(k=i; p<13; k++)
{
if(k>=strlen(str))
break;
p=p*10+str[k]-'0'; //???????str... | ALGO | 0.999893 | 3.065819 |
f3dd1399-fe6e-4e8b-b8a1-e41416551747 | sinian666/codes_102_1 | cpp_副本24/chapter_array_and_linkedlist/array.cpp | /**
* File: array.cpp
* Created Time: 2022-11-25
* Author: Krahets (<EMAIL>)
*/
#include "../utils/common.hpp"
/* 随机返回一个数组元素 */
int randomAccess(int *nums, int size) {
// 在区间 [0, size) 中随机抽取一个数字
int randomIndex = rand() % size;
// 获取并返回随机元素
int randomNum = nums[randomIndex];
return randomNum;
... | ALGO | 0.915986 | 4.8213 |
06c7ad18-61fe-46ca-8378-5aa75a15a303 | PedroHMNobrega/Programming-Problems | URI/Strings/2880.cpp | //Enigma
//Assunto: String;
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLON... | ALGO | 0.999958 | 3.76782 |
a0519a07-1f1c-4cf7-912a-a2a6e4bba375 | aseemrb/competitive | c++/marblegf.cpp | #include <iostream>
#include <string.h>
#include <cstdlib>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include ... | ALGO | 0.999529 | 3.509037 |
382e16c6-9dc8-4b5a-a787-17f2b8c5bf60 | RamazanFIT/pp1 | 15/version2.cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
int massive[10];
for(int i = 0; i < 10; i++){
massive[i] = 0;
}
while (true)
{
int x;
cin >> x;
if(x == 0) break;
massive[x]++;
}
for(int i = 1; i <= 9; i++){
cout << massive... | ALGO | 0.999687 | 4.00954 |
36e8c5ec-27e3-4268-a9a0-e2609ed71afa | Ab-mahin/Light-OJ | LOJ-1090.cpp | // USER: "Ab.Mahin"
// Problem: Trailing Zeroes (II)
// Contest: LightOJ
// URL: https://lightoj.com/problem/trailing-zeroes-ii
// Memory Limit: 64 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_poli... | ALGO | 0.999507 | 4.459585 |
280a3337-253c-46ce-adcf-e7fcd8b40c98 | LalithaMangalamM/techdose-training-assignments | 137-single-number-ii/single-number-ii.cpp | class Solution {
public:
int singleNumber(vector<int>& nums) {
int ones = 0;
int twos = 0;
for (const int num : nums) {
ones ^= (num & ~twos);
twos ^= (num & ~ones);
}
return ones;
}
}; | ALGO | 0.999894 | 5.845248 |
8bf77255-a273-40a5-9451-b1d13e9b0287 | milleniumcore/CactusEMU | src/server/scripts/EasternKingdoms/boss_kruul.cpp | /* ScriptData
SDName: Boss_Kruul
SD%Complete: 100
SDComment: Highlord Kruul are presumably no longer in-game on regular bases, however future events could bring him back.
SDCategory: Bosses
EndScriptData */
#include "ScriptPCH.h"
#define SPELL_SHADOWVOLLEY 21341
#define SPELL_CLEAVE 20677
#def... | TOOL | 0.887164 | 6.222254 |
b44bf4d0-e9c6-4916-bd34-184ab3c76eb0 | Shwet310/LeetCode__Practice | 0951-flip-equivalent-binary-trees/0951-flip-equivalent-binary-trees.cpp | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), l... | ALGO | 0.999995 | 6.854004 |
feea8dfd-4991-4c3b-bf3c-691d3528658e | khardiashab/Dsa-sheet-question | pr_067.cpp | // Given a string S consisting of only opening and closing curly brackets '{'
// and '}', find out the minimum number of reversals required to convert the string
// into a balanced expression.
// A reversal means changing '{' to '}' or vice-versa.
#include <bits/stdc++.h>
using namespace std;
int countReversal(string... | ALGO | 0.998946 | 5.618056 |
8bc67bd7-d671-49bc-8455-906bc9e8a111 | yRamosz/Meu-projeto | 22.04/exercC.cpp | #include <iostream>
using namespace std;
int main() {
int n, f = 1;
cout << "Digite um numero inteiro: ";
cin >> n;
if (n < 0) {
cout << "Fatorial nao existe para numeros negativos." << endl;
} else {
int i = 1;
while (i <= n) {
f *= i;
i++;
... | ALGO | 0.999697 | 4.872423 |
bb908168-4d05-4d30-9499-6a878cf88157 | Codehackerone/dsa-practice | practice/Binarytrees/countleaf.cpp | #include<iostream>
using namespace std;
template<typename T>
class BTNode{
public:
T data;
BTNode* left;
BTNode* right;
BTNode(T data){
this->data = data;
left = NULL;
right = NULL;
}
~BTNode(){
delete left;
... | ALGO | 0.999796 | 4.461732 |
2435774d-416e-405a-b60e-e767c40fa95f | hudilman/kumpulan_cpp_program | circular_queue.cpp | #include <iostream>
using namespace std;
int cqueue[5];
int front = -1, rear = -1, n=5;
void insertCQ(int val) {
if ((front == 0 && rear == n-1) || (front == rear+1)) {
cout<<"Queue Overflow \n";
return;
}
if (front == -1) {
front = 0;
rear = 0;
} else {
if (rear == n - 1)
... | ALGO | 0.992056 | 3.90804 |
3b7a6e05-aa5f-4fb0-ba92-89e81bddfa78 | jujo-k/OFF | Project1/10021/10021/10021.cpp | #include <iostream>
#include <string>
using namespace std;
int main() {
string s;
cin >> s;
int len = s.length();
int *a = new int [len];
int sum = 0;
string str[10] = {"ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu"};
for (int i = 0; i < len; i++) {
a[i] = s[i] - '0';
sum = sum + a[i];
}
... | ALGO | 0.999921 | 3.424471 |
5e6c4dad-e46c-4a07-b215-12a2d4587894 | abhiram138b/LEETCODE | 1859-sorting-the-sentence/1859-sorting-the-sentence.cpp | class Solution {
public:
string sortSentence(string s) {
string str = "";
map<int,string> mp;
for(auto it : s){
if(it == ' '){
char ch = str.back();
str.pop_back();
mp[ch] = str;
str = "";
}else{... | ALGO | 0.99999 | 6.079074 |
8376ed65-bd53-4304-977e-8b67d9ff4e14 | danache/coding | etc/mianshi161002/mianshi161002/main.cpp | #include <iostream>
using namespace std;
#define MAXN 1005
int query(int m){
return 1;
}
bool ischoose[MAXN];
int value[MAXN];
bool status[MAXN][MAXN];
bool isconnected(int m, int n){
return status[m][n];
}
int getMax(int n, int *p){
if (n == 1){
int tag = -1;
int temp = 0;
for(int... | ALGO | 0.999895 | 3.439563 |
b862cfce-46fe-4342-aa96-98492275b0d9 | nlowe/EECS2510 | MinimumSpanningTrees/SpanningTree.cpp | #include "stdafx.h"
#include <iostream>
#include "SpanningTree.h"
SpanningTree::SpanningTree()
{
// Store the edges as a minimum priority queue sorted first by the first vertex alphabetically,
// then by the second vertex alphabetically. This lets us print the tree without having to sort
// the edges later
edges ... | ALGO | 0.997498 | 5.33144 |
6fcdcb11-826e-4b47-926f-d32f4d643365 | Waterforces/Competitive-programming | POSN/SU_66_67/Camp1/OlympicMedal.cpp | #include<bits/stdc++.h>
using namespace std;
typedef struct medal {
bool check;
int gold,silver,bronze,all;
} medal;
map<int,medal> mp;
vector<int> idx;
int n,a;
int main() {
cin >> n;
for(int i=0;i<n;i++) {
int id,g,s,b;
cin >> id >> g >> s >> b;
idx.push_back(id);
mp[i... | ALGO | 0.9955 | 3.51098 |
c6f174ac-d58d-4715-9c93-35d127366c8f | Mourya8/LeetCode-Solutions | 1927. Maximum Ascending Subarray Sum/Solution.cpp | class Solution {
public:
int maxAscendingSum(vector<int>& nums) {
int maxSum=nums[0];
int tempSum=nums[0];
for(int i=1;i<nums.size();i++)
{
if(nums[i]>nums[i-1])
{
tempSum+=nums[i];
}
else{
tempSum=nums[i... | ALGO | 0.999976 | 6.124647 |
07ee4d12-a025-4dc1-97f1-dba7c7151ccd | kaushalboii/data-structure | Binary search.cpp | #include <stdio.h>
int binarySearch(int arr[], int size, int key)
{
int left = 0;
int right = size - 1;
while (left <= right)
{
int mid = left + (right - left) / 2;
if (arr[mid] == key)
{
return mid;
}
if (arr[mid] < key)
{
left = mid + 1;... | ALGO | 0.999894 | 6.066362 |
7d9cf89f-909c-46df-add1-b7f6d9e38c20 | Palmkonde/CompetitiveProgramming | OTOG/Mogu4_0/Mogu4_0.cpp | #include <bits/stdc++.h>
using namespace std;
int n, q;
int num[505];
int dp[505][22][22];
int paint(int now, int st, int nd)
{
if (now >= n)
return 0;
if (dp[now][st][nd] != -1)
return dp[now][st][nd];
int res = INT_MAX;
//เปลี่ยนแปลงแรก
if (num[now] != st)
{
res = ... | ALGO | 0.999854 | 4.349323 |
e205f1d8-92d9-4fe0-9c55-97876dd27218 | bhanujggandhi/ds-algo-learn | old/2.4loops/next_greater.cpp | #include <iostream>
#include <vector>
using namespace std;
int printNGE(vector<int> Arr, int element)
{
int next;
cout << Arr[element] << endl;
for (int j = element; j < Arr.size(); j++)
{
if (Arr[j] > Arr[element])
{
next = Arr[j];
break;
}
}
return next;
}
int main()
{
vector<int> arr = {11, 1... | ALGO | 0.999693 | 4.234548 |
8b6f7052-eb81-41af-bb63-2150b50afbc4 | jebouin/CompetitiveProgramming | CodeForces/CF1041-D2-D.cpp | /*
* Author: Jeremy Bouin
*
* Idea:
* - Using prefix sum and binary search, we can compute the total length of air flow between any two
* coordinates in O(log n) time.
* - The optimal flight starts from the beginning of an air flow, so we can check in O(n log n) time
* ... | ALGO | 0.999937 | 4.551777 |
2c7d88c3-58e7-420a-b50d-02c63a0d3a70 | shyamal2411/DSA-Practice | leetcodePractice/Greedy/FractionalKnapsackGFG.cpp | #include <bits/stdc++.h>
using namespace std;
// https://practice.geeksforgeeks.org/problems/fractional-knapsack-1587115620/1
struct Item{
int value;
int weight;
};
bool compare(Item a, Item b){
double r = (double) a.value / (double) a.weight;
double w = (double) b.value / (double) b.weigh... | ALGO | 0.999974 | 5.182038 |
e7891007-8516-4fdc-8dfd-a1e01a9a8736 | neverac/2020summer | 个人赛6/G/26613358_maomaoyu804_G.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll a,b;cin>>a>>b;
ll ans=0;
if(a>b) ans+=a/b,a%=b;
while(a){
if(a==1){
ans+=b;
break;
}
ans+=b/a;
b%=a;
swap(a,b);
}
cout<<ans<<endl;
return 0;
} | ALGO | 0.999963 | 3.847507 |
862bebf2-74ed-4950-af3a-647527cc3203 | pra11chit/algorithms | math/prime/seiveOfErasthones.cpp | #include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
int n = 100;
vector<bool> is_prime(n + 1, true);
is_prime[0] = is_prime[1] = false;
for (int i = 2; i*i <= n; ++i) {
if (is_prime[i]) {
for(int j = i*i; j <= n; j += i)
is_prime[... | ALGO | 0.999028 | 4.507196 |
c18399f0-26bb-450e-abbc-b233dbca27fd | NirSeg/CSES | CSES Problem Set/Dynamic Programming/countingTowers.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(ll i = a; i < b; i++)
ll dp[ll(1e6)];
ll maxTower = 1e6, mod = 1e9 + 7;
int main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll t, tower;
dp[0] = 2, dp[1] = 8;
rep(i, 2, maxTower)
dp[i] = (... | ALGO | 0.999791 | 4.475159 |
08c3a214-14d7-4325-b47f-aa06895a0d60 | rawagiha/cpp_primer | cppbook_by_yabukitaro/chapter_10/10.2.ConstructorDestructor/10.2.8-move_4.cpp | #include <iostream>
#include <string>
#include <vector>
class Person {
public:
std::string* name;
int age;
std::vector<int> v;
Person() : name(new std::string) {}
~Person() { delete name; }
Person(const Person& x) : name(new std::string(*(x.name))), age(x.age), v(x.... | TOOL | 0.906327 | 5.187215 |
1b7a34c5-0e02-4b5b-ab76-40137a962d3d | Bondok6/Algorithm | N Queen/main.cpp | //N-Queen problem
//order N^2
//backtracking algorithm
#include <iostream>
#include<stdlib.h> // abs()
using namespace std;
int a[30]; int Count=0;
void print_sol(int n);
void queen(int n);
int main()
{
int num;
cout<<"Enter the number of Queen >> ";
cin... | ALGO | 0.999849 | 4.456323 |
025d64f3-1caa-45db-b4d2-99f802647efa | harshith1103/DSA0170 | happy number.cpp | #include<iostream>
using namespace std;
int main()
{
int n,i,sum=0;
cin>>n;
while(sum!=1&&sum!=4){
sum=0;
while(n>0)
{
i=n%10;
sum=sum+i*i;
n=n/10;
}
n=sum;
}
if(sum==1)
cout<<"happy number";
else
cout<<"not happy number";
return 0;
}
| ALGO | 0.99996 | 3.27292 |
7fb678ec-e937-46f0-ba42-99ce83fe36bc | satwikgm/LeetCode | 1312-minimum-insertion-steps-to-make-a-string-palindrome/1312-minimum-insertion-steps-to-make-a-string-palindrome.cpp | class Solution {
public:
int lcs(string s1,string s2,int n)
{
int dp[n+1][n+1];
for(int i=0;i<=n;i++)
{
for(int j=0;j<=n;j++)
{
if(i==0 || j==0)
{
dp[i][j]=0;
}
}
}
for... | ALGO | 0.999994 | 6.063744 |
f2b290f5-e46d-4177-b9ed-5b332853b9d5 | GuacheSuede/MSSubmission1234567890 | submission/ema/boost_1_69_0/libs/compute/perf/perf_bolt_inner_product.cpp | #include <iostream>
#include <algorithm>
#include <vector>
#include <bolt/cl/inner_product.h>
#include <bolt/cl/copy.h>
#include <bolt/cl/device_vector.h>
#include "perf.hpp"
int main(int argc, char *argv[])
{
perf_parse_args(argc, argv);
std::cout << "size: " << PERF_N << std::endl;
bolt::cl::control ... | ALGO | 0.937905 | 5.112864 |
0df0d74b-d5f3-48d9-a248-a922aa3bf499 | yveslox/Genesisras | practice-code-orange/programme-c++/vector-union.cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
//union of two vectors
vector<int> v1;
v1.push_back(1);
v1.push_back(22);
v1.push_back(3);
v1.push_back(4);
sort(v1.begin(),v1.end());
vector<int> v2;
v2.push_back(3);
v2.push_back(41);
v2.push_back(9);
v2.push_back(10);
sort(v2.begin(),v2.end());
vector<int... | ALGO | 0.999227 | 3.796497 |
3469c92f-7f99-4ba3-8665-e9b3b12bd530 | alexandraback/datacollection | solutions_5648941810974720_1/C++/koensw/A.cpp | #include <iostream>
#include <cassert>
int c[27] = {};
std::string l[] = {"ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE"};
char i1[] = {'Z', 0, 'W', 0, 'U', 0, 'X', 0, 'G', 0};
char i2[] = {0, 'O', 0, 'H', 0, 'F', 0, 'S', 0, 0};
int ans[10] = {};
int main(){
int T;
std::cin >> ... | ALGO | 0.999479 | 5.175461 |
b01e4e17-a4e7-49b6-9e04-cc21402827dc | belanasaikiran/DSA-OS-Others | OperatingSystemsKernelFuncs/MutexAtmoicOperations.cpp | #include <iostream>
#include <atomic>
#include <thread>
#include <vector>
using namespace std;
class simpleMutex{
private:
std::atomic_flag lock_flag = ATOMIC_FLAG_INIT;
public:
void lock(){
// Spin until we acquire the lock
while(lock_flag.test_and_set(std::memory_order_acquire));
... | TOOL | 0.94157 | 5.330087 |
6f3d92fc-4afa-435b-bc97-bd397a18c91b | BonhyeonGu/BOJ | BOJ_2441_별찍기-4.cpp | #include <stdio.h>
int main()
{
int a;
scanf("%d", &a);
for (int i = 0; i < a; i++)
{
for (int j = 0; j < i; j++)
{
printf(" ");
}
for (int j = a; j-i > 0; j--)
{
printf("*");
}
printf("\n");
}
} | ALGO | 0.999952 | 3.60072 |
fd72de0d-fb4b-400b-9d55-0f7f69692115 | grinisrit/noa | src/noa/3rdparty/tnl-noa/Documentation/Tutorials/Matrices/DenseMatrixExample_reduceRows_maxNorm.cpp | #include <iostream>
#include <iomanip>
#include <functional>
#include <TNL/Matrices/DenseMatrix.h>
#include <TNL/Devices/Host.h>
template< typename Device >
void reduceRows()
{
TNL::Matrices::DenseMatrix< double, Device > matrix {
{ 1, 0, 0, 0, 0 },
{ 1, 2, 0, 0, 0 },
{ 0, 1, 8, 0, ... | ALGO | 0.996898 | 5.959474 |
e26042f6-1b2e-4345-9da2-fe417bca4e77 | sudarshanvm/problem-solving | leetcode/61.cpp | //problem: https://leetcode.com/problems/rotate-list/
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *next) : val(x), next(next) {}
* };... | ALGO | 0.999982 | 5.815349 |
4f80d35e-6a23-45fc-bf36-4ca029857a34 | Aram-Davtyan/Zdes | 5.1б/2. Дядя Ньютон/ConsoleApplication1/ConsoleApplication1/ConsoleApplication1.cpp |
#include <iostream>
#include <vector>
#include <fstream>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
void read_data(vector <double>& x, vector <double>& y) {
ifstream fin;
fin.open("data.txt");
if (!fin.is_open()) {
cout << "Error reading the file" << endl;
system("pause");
}
double tmp;... | ALGO | 0.998646 | 3.123861 |
b8c64213-abf0-4cec-b3a0-af28a478f34c | siddharth-patel-23/Algorithms-on-Graphs | week1_decomposition1/1_reachability/reachability.cpp | #include <iostream>
#include <vector>
using std::vector;
using std::pair;
int reach(vector<vector<int> > &adj, int x, int y) {
//write your code here
return 0;
}
int main() {
size_t n, m;
std::cin >> n >> m;
vector<vector<int> > adj(n, vector<int>());
for (size_t i = 0; i < m; i++) {
int x, y;
st... | ALGO | 0.999929 | 4.348797 |
6f81d587-2fe1-408e-995d-1f693d21780e | sushantkumar143/Competitive-Programming | CodeForces/A_Bear_and_Big_Brother.cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
long long n, m;
cin >> n >> m;
int cnt = 0;
while(n <= m){
n *= 3;
m *= 2;
cnt++;
}
cout << cnt;
} | ALGO | 0.999901 | 4.205741 |
13a323c9-22fd-4e0a-a738-2b1274657ca6 | ishandutta2007/codeforces | izban/normal/799/E.cpp | #include <unordered_map>
#include <unordered_set>
#include <functional>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
#include <map>
#include <math.h>
#include <cstdio>
#include <set>
#include <de... | ALGO | 0.999986 | 3.752562 |
035ab2eb-a82f-4f2c-b755-b755bd8bd4df | yusifaliyevpro/Competitive-Programming | LeetCode/Hard/1840. Maximum Building Height.cpp | // 1840. Maximum Building Height
// https://leetcode.com/problems/maximum-building-height/
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int maxBuilding(int n, vector<vector<int>>& restrictions) {
}
}; | ALGO | 0.999499 | 5.95397 |
afe45a32-98ef-44d6-ac3d-a8a331b18ad3 | towhid1zaman/Different_OnlineJudge_Solutions | UVA_Solutions/Mathematics/10311 - Goldbach and Euler.cpp | /*これを翻訳している間、あなたはあなたの人生のいくつかの貴重な瞬間を無駄にしました*/
#pragma comment (linker,"/STACK:16777216")
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
#define endl "\n"
#define pb push_back
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(in... | ALGO | 0.999523 | 4.297569 |
fa0e0f55-34a9-4b56-8092-2b2139e9f346 | tada0389/MyAtCoder | dfsC.cpp | #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
using namespace std;
/*
vector<vector<char>> field;
vector<vector<int>> landNum;
void dfs(int x, int y, int num) {
field[x][y] = 'x';
landNum[x][y] = num;
for (int dx = -1; dx <= 1; dx++) {
if (field[dx + x][y] == 'o')... | ALGO | 0.999414 | 4.143538 |
5392bfb8-b903-4124-8f2f-77c90a1f5ab6 | ArunRathaur1/LeetcodeCodes | 2375-minimum-obstacle-removal-to-reach-corner/2375-minimum-obstacle-removal-to-reach-corner.cpp | class Solution {
public:
int minimumObstacles(vector<vector<int>>& grid) {
int row=grid.size();
int col=grid[0].size();
priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<>> q;
vector<pair<int,int>>directions={{0,1},{1,0},{-1,0},{0,-1}};
vector<vector... | ALGO | 0.99998 | 5.958403 |
e8c13cfb-34c7-48f8-95a9-0a68ff11efb7 | gt1/libmaus | src/libmaus/util/NearestNeighbourDictionary.cpp | #include <libmaus/util/NearestNeighbourDictionary.hpp>
uint64_t libmaus::util::NearestNeighbourDictionary::byteSize() const
{
return
m_abs_samples->byteSize() +
m_differences->byteSize() +
m_contains_abs_sample->byteSize() +
2*sizeof(uint64_t);
}
uint64_t libmaus::util::NearestNeighbourDictionary::size() con... | ALGO | 0.975764 | 5.294802 |
02a920fe-c697-43a8-909e-d6cba204988c | itsmeJamesproprogrammer/codingProjects | Teveslab1 (1).cpp | /*
Developed by: James Ald Teves
Comp Scie 23 - B
Lab 1
Instructor: Assist. Prof. Allan V. Credo
*/
//Preprocessor Directives
#include <iostream>
#include <conio.h>
#define NEWLINE '\n';
using namespace std;
//Functions declarations
double power(double n, int p = 2);
//Main Driver
int main (void) {
int newPow;... | ALGO | 0.995547 | 5.854518 |
476936f9-0f3a-4ee5-8b7b-33a81e9738bf | ParkDaeYi/Uva | Heap.cpp | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#define HEAP_SIZE 256
#define ARRAY_SIZE 10
using namespace std;
template<class T> class Heap {
private:
T* heap;
int sz;
void swap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
public:
Heap() {
heap = new T[];
sz = 0;
}
int size() {
... | ALGO | 0.999918 | 4.556055 |
ebdc72bc-6a88-4929-a181-d1b6ced6d057 | InwooLeeme/Algorithm | Boj/19575.cpp | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds... | ALGO | 0.999899 | 4.58024 |
68b72070-6377-4ea2-9693-4d4f9d823c5a | penguinway/ORGCTF2024-FLAG | 2580.cpp | #include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 150;
map<string , int > mp;
int main()
{
int t;
cin >> t;
while (t--)
{
string a;
cin >> a;
mp[a] = 1;
}
cin >> t;
... | ALGO | 0.998356 | 3.979732 |
3a785b6f-dc83-4905-91f2-a2ebe4747178 | hiro999999999/opencv | opencv_007.cpp | //Cで書いた3x3の移動平均オペレータ。OpenCVの答え合わせ付
#include <iostream>
#include <cmath>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(){
std::string win_src = "src";
std::string win_gray = "gray";
std::string win_dst = "dst";
std::string file_src = "src.png";
std::string file_gray = "gray.png";
std... | ALGO | 0.991242 | 3.481843 |
aa4c0c28-8604-452d-b95b-d003d5a5f9e8 | Kushagra-Mangalam/PEP_DSA_KUSH | dsa/old/del_tail_linked_list.cpp | #include<iostream>
using namespace std;
struct node{
int data;
node *prev;
node *next;
node(int d){
data=d;
prev=NULL;
next=NULL;
}
};
void printlist(node *head){
node *curr=head;
while(curr!=NULL){
cout<<curr->data<<" ";
curr=curr->next;
}
cout<<endl;
}
node *deltail(node *head){
if (head==NUL... | ALGO | 0.999486 | 4.411139 |
eb4ccb96-6043-4384-99da-ea4f6f3cf575 | tienit150198/ACM | codeforces/1133C/main.cpp | #include <bits/stdc++.h>
#define ll long long int
#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Max 200007
using namespace std;
ll n;
ll a[Max];
ll isSearch(ll a[], ll l, ll r, ll key){
ll mid = (l + r ) / 2;
ll ans = -1;
while(l <= r){
mid = (l + r) / 2;
... | ALGO | 0.999914 | 4.098848 |
263b90f0-1e15-4cc6-818c-c625299f39d8 | enochjung/acmicpc_net | 09/9426.cpp | #include <cstdio>
int n, k, a[250010];
int t[131090];
long long res;
int get(int v)
{
int x = 1;
while(x < (1<<16))
{
if(v <= t[x*2])
x *= 2;
else
{
v -= t[x*2];
x = x*2+1;
}
}
return x-(1<<16);
}
void set(int x, int v)
{
x += 1<<16;
t[x] += v;
for(; x>1; x/=2)
t[x/2] = t[x]+t[x^1];
}
int... | ALGO | 0.99985 | 3.691317 |
92b0cb47-1dad-4b15-9029-2fc9832da2a0 | Srutarshi-Ghosh/C-and-Cpp-Programs | Job_Sequence.cpp | #include<stdio.h>
#include<stdlib.h>
typedef struct job{
int id;
int deadline;
int profit;
}job;
void jobSort(job*, int);
void swapJob(job*, int, int);
int min(int, int);
void printJobs(job*, int);
int job_sequence(job*, int, int);
int main(){
job *job_list;
int i, n, max_deadline, max_profit;
printf("Enter ... | ALGO | 0.99996 | 4.257041 |
496a9d29-604d-4ca5-b5de-99a0ff7a77da | WOONBE/C__Algorithm | BackTracking/eggtoEgg.cpp | //
// Created by 김헌우 on 2023/07/09.
//
#include "bits/stdc++.h"
using namespace std;
int n;
int dur[10],wei[10]; //내구도와 무게 저장할 array
int mx=0;
int num=0; //깨진 계란의 수
void start(int a){
if(a == n){
mx = max(mx,num);
return; //빼먹어서 런타임 오류발생
}
if(dur[a] <=0 || num == n-1){
start(a+1... | ALGO | 0.999882 | 4.416528 |
deeef360-51fd-4e38-ad33-45cdaf11f7f5 | upadhyay-prashant/codechef | april_17_cook_off/xorsums.cpp | #include<iostream>
#include<vector>
#include<stdio.h>
#include<map>
#include<algorithm>
#include<bitset>
#include<cstring>
#include<limits.h>
#include<queue>
#include<vector>
using namespace std;
int main(){
int n;
scanf("%d",&n);
int a[300010];
int sum[300010];
int temp;
for(int i=1;i<=n;i++){
scanf("... | ALGO | 0.999982 | 3.588157 |
3ac1c136-ebd3-4f43-b79d-ddb06fd82947 | AppSalmon/Competition-programming-notebook | Tailieu/Tai Lieu Cua HV BCVT/STL Algorithm/Demo 3.2.cpp | #include <iostream>
#include <algorithm>
using namespace std;
int a[]={1,2,3},b[]={4,5,6};
int x=1,y=2;
int main() {
swap(x,y); //doi cho 2 bien int
cout << "x=" << x << endl;
cout << "y=" << y << endl;
swap(a,b); // doi cho 2 mang int
cout << "a = { ";
for (int i=0;i<3;i++) cout << a[i] << " ... | ALGO | 0.989663 | 3.537049 |
5dd7b0f0-75b5-4d9a-af43-944fac73b75d | aplqo/exercises | codeforces/587E-DuffAsQueen.cpp | #ifdef APTEST
#include "debug_tools/judge.h"
#endif
#include <algorithm>
#include <cstring>
#include <iostream>
#include <iterator>
const int maxN = 2e5, maxLog = 29;
class LinearBasis {
public:
void init(const unsigned int x)
{
std::memset(val, 0, sizeof(val));
insert(x);
}
void insert(unsigned int x... | ALGO | 0.999739 | 4.814175 |
0e85ad8a-088c-473d-b21d-7dbd70c4e6b6 | matumoto1234/cp-crawler | AtCoder/arc113/arc113_c/27466395.cpp | // detail: https://atcoder.jp/contests/arc113/submissions/27466395
#include <bits/stdc++.h>
using namespace std;
// {{{ templates
// clang-format off
// Macros
#define over_load_(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) over_load_(__VA_ARGS__, rep4, rep3, rep2)(__VA_ARGS__)
#define rep2(i, r) for ( int i = 0; i <... | ALGO | 0.999955 | 5.504326 |
023c47ef-9854-48d3-af60-139e4bca1e85 | madratman/ardupilot_gym_gazebo | libraries/SITL/SIM_Multicopter.cpp | /// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
/*
multicopter simulator class
*/
#include "SIM_Multicopter.h"
#include <stdio.h>
namespace SITL {
Motor m(90, false, 1);
static const Motor quad_plus_motors[4] =
{
Motor(90, false, 1),
Motor(270, false, 2),
Motor(0, ... | TOOL | 0.889219 | 7.023129 |
f2ac71de-2e4e-4ed2-9ac1-a13cb7431beb | the-t3ch-wizard/Dsa-Practice | Self Practice/LinkedList/Doubly Linked List/PrintDLL.cpp | #include <iostream>
using namespace std;
class node{
public:
int val; node* pre; node* nxt;
node(int n){
val=n; pre=NULL; nxt=NULL;
}
};
void print(node* head){
while (head!=NULL){
cout << head->val << " ";
head=head->nxt;
}
cout << endl;
}
void insert(node* &... | ALGO | 0.998501 | 4.7729 |
a8de1b23-aeb7-41f3-bd1e-686e0a762d6f | safiullah-foragy/Competetive-programming | balanced_round.cpp |
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
void solve()
{
int n;
ll k;
cin>>n>>k;
set<ll>st;
vector<ll>v(n);
for(auto &i:v)
{
cin>>i;
}
sort(v.begin(),v.end());
int cnt=1,max1=1;
for(int i=1;i<n;i++)
{
if(v[i]-v[i-1]>k){cnt=1;}
else {cnt++;}
max1=max(max1,cnt);
}
cout<<n-max... | ALGO | 0.999869 | 3.852189 |
62b92a18-5534-4177-b88a-e9b188424dc4 | dmitrykitty/OOP_C_plus | ex2-4-lambda-functions/practise2.cpp | #include <iostream>
enum {max_length_ar = 20};
using filter_func = bool (*)(short);
void remove_elem(short* ar, int& len, filter_func filter)
{
int removed = 0;
for(int i = len - 1; i >= 0; --i){
if(filter(ar[i])){
for(int j = i; j < len - 1; j++)
ar[j] = ar[j + 1];
... | TOOL | 0.998295 | 3.788126 |
acaac59c-3c90-46bd-a5af-948112fe20d1 | vipul-kumar455/GeeksForGeeks-problem-of-the-day | Stack/The Celebrity Problem.cpp | class Solution
{
public:
//Function to find if there is a celebrity in the party or not.
bool know(vector<vector<int> >& M,int a, int b, int n)
{
if(M[a][b]==1)
return true;
else
return false;
}
int celebrity(vector<vector<int> >& M, int n)
{
... | ALGO | 0.999885 | 5.302892 |
7b0f4db9-915e-4cb4-a8e7-847c9efc374e | ishandutta2007/codeforces | .tx/normal/884/B.cpp | #include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;
#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)
#define STRESS 0
using lint = long long;
void so... | ALGO | 0.999984 | 3.814795 |
377d6b2f-e781-46ba-be67-54a7429b974d | KurodaKanbei/ACM | Template of other teams/Grimoire/Template/source/computational-geometry/point-in-polygon.cpp | bool InPoly(P p,vector<P>poly){
int cnt=0;
for(int i=0;i<poly.size();i++){
P a=poly[i],b=poly[(i+1)%poly.size()];
if(OnLine(p,L(a,b)))
return false;
int x=sgn(det(a,p,b));
int y=sgn(a.y-p.y);
int z=sgn(b.y-p.y);
cnt+=(x>0&&y<=0&&z>0);
cnt-=(x<0&&z<=0&&y>0);
}
return cnt;
}
| ALGO | 0.999832 | 4.540242 |
2b501f96-e4df-4bba-ad20-36a66f9198a7 | rrrs07/DSA_practice | recursion/fibonacci.cpp | class Solution {
public:
int fib(int n) {
// Base Condition.
if(n<= 1)
{
return n;
}
// Problem broken down into 2 functional calls
// and their results combined and returned.
int last = fib(n-1);
int slast = fib(n-2);
return last + slast;
}
}; | ALGO | 0.99995 | 6.47537 |
b9ea3924-9e9c-4a82-98ea-1760c0afbe64 | tnViet/CPP_Ptit | cpp0133 uoc so nguyen to nho hon n.cpp | #include <iostream>
#include <cmath>
using namespace std;
int nt(int a){
for(int i=2;i<=sqrt(a);i++){
if (a%i==0)
return 0;
}
return 1;
}
int main(){
int t;cin>>t;
while (t--){
int n;cin>>n;
for(int i=2;i<=n;i++){
if (nt(i)==1) cout<<i<<" ";
}
cout<<endl;
}
return 0;
} | ALGO | 0.998843 | 4.724356 |
cf7dde60-a277-4581-92b1-6f95ef163ec1 | Golovanov399/adventofcode | 2020/02_b.cpp | #include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define itn int
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())
using namespace std;
inline int nxt() {
int x;
scanf("%d", &x);
return x;
}
int main() {
int cnt = 0;
for (int i = 0; i < 1000... | ALGO | 0.996317 | 3.684879 |
b4d54fbc-5a14-4050-86a4-385195f4e8ae | Xilinx/llvm-aie | llvm/lib/Transforms/IPO/Inliner.cpp | #include "llvm/Transforms/IPO/Inliner.h"
#include "llvm/ADT/PriorityWorklist.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include ... | TOOL | 0.920524 | 6.582067 |
5755fcfd-f328-4677-88cb-90defc80a166 | JuncoDH/CompetitiveProgramming | online_judges/AceptaElReto/130.cpp | #include <iostream>
#include <math.h>
#include <string.h>
using namespace std;
#define MAX 1000
int main() {
int n, x1, y1, x2, y2;
while (1) {
cin >> n;
if(!n){
return 0;
}
cin >> x1 >> y1 >> x2 >> y2;
if((x1+y1)%2!=(x2+y2)%2){
cout<<"IMPOSIBLE\n";
continue;
}
if(x1==x2 && y1==y2){
cout<... | ALGO | 0.999311 | 3.831651 |
a75e67ed-d04f-4d2a-b51b-d97353f41565 | bilalelsheemy/Steering-Throttle-Model-Predictive-Control | src/Eigen-3.3/blas/double.cpp | #define SCALAR double
#define SCALAR_SUFFIX d
#define SCALAR_SUFFIX_UP "D"
#define ISCOMPLEX 0
#include "level1_impl.h"
#include "level1_real_impl.h"
#include "level2_impl.h"
#include "level2_real_impl.h"
#include "level3_impl.h"
double BLASFUNC(dsdot)(int* n, float* x, int* incx, float* y, int* incy)
{
... | ALGO | 0.994707 | 5.138801 |
1a9f9b93-cb18-43ff-9e3a-4282940c8e0f | ishandutta2007/codeforces | zxqfl/normal/232/A.cpp | #include <bits/stdc++.h>
using namespace std;
#define jjs(i, s, x) for (int i = (s); i < int(x); i++)
#define jjl(i, x) jjs(i, 0, x)
#define ji(x) jjl(i, x)
#define jj(x) jjl(j, x)
#define jk(x) jjl(k, x)
#define jij(a, b) ji(a) jj(b)
#define ever ;;
#define foreach(x, C) for (auto& x : (C))
#define INF ((int) 1e9+10)... | ALGO | 0.99985 | 3.412874 |
e293a076-346b-4ef3-93cd-5a381190ac38 | ishandutta2007/codeforces | stupid_justin/normal/441/E.cpp | #include<bits/stdc++.h>
#define int long long
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#define rd(x) x=read()
#define wt(x) write(x)
#define pos(x) (((x)-1)/SZ+1)
using namespace std;
const int N=200+5;
const in... | ALGO | 0.999892 | 3.417214 |
2f722d6c-ab5a-41c2-8384-285ed9f0d62f | invrev/ctci | prog_challenge/wiggleSort.cpp | #include<iostream>
#include<algorithm>
using namespace std;
//WiggleSort
//Given a sorted array, and re-arrange it to wiggle style in one pass.
//i.e. [1] A0 >= A1 <= A2 >= A3 .... .... An.
// [2] A0 <= A1 >= A2 <= A3 .... .... An.
//Swap the neighbours
void WiggleSort(int a[],int n) {
//sort the array
s... | ALGO | 0.999916 | 4.509727 |
d10b51e7-bbb5-44df-af06-2cb314db063f | WeijianPeng/USACO-traning-code | ariprog (2).cpp | /*
ID:pen_wan1
LANG:C++
TASK:ariprog
*/
#include <iostream>
#include <stdio.h>
#include <time.h>
#include<algorithm>
#include<assert.h>
using namespace std;
typedef struct
{ int a;
int b;
}ariprog;
ariprog Ariprog[10000];
int bsquaretemp[130000+10],
bsquare[130000+10],z=0;
int cmp(int i,int j)
{ return Aripr... | ALGO | 0.999857 | 3.187746 |
4129749f-fa6c-4827-9cc7-0f780819737d | NoyonKhan12/LEETCODES | 1470-shuffle-the-array/1470-shuffle-the-array.cpp | class Solution {
public:
vector<int> shuffle(vector<int>& nums, int n)
{
vector<int> s;
for(int i=0, j=n; i<n, j<(2*n); i++, j++)
{
s.push_back(nums[i]);
s.push_back(nums[j]);
}
return s;
}
}; | ALGO | 0.99997 | 6.232823 |
16d40b9f-d0b0-4860-8c5a-30f7b1267094 | zhangsir293/algo | test/oncefindnum.cpp | // 给你一个 非空 整数数组 nums ,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。
// 你必须设计并实现线性时间复杂度的算法来解决此问题,且该算法只使用常量额外空间。
// 示例 1 :
// 输入:nums = [2,2,1]
// 输出:1
// 示例 2 :
// 输入:nums = [4,1,2,1,2]
// 输出:4
// 示例 3 :
// 输入:nums = [1]
// 输出:1
#include<unordered_set>
#include<iostream>
#include<vector>
using namespace std;
int main... | ALGO | 0.999617 | 4.977723 |
6fce95ba-8c3a-447e-bfde-f82e3fa494ce | VishalPatil18/My-CPP-Solutions | Leetcode/453. Minimum Moves to Equal Array Elements.cpp | // My Solution - Brute Force
class Solution {
public:
int minMoves(vector<int>& nums) {
int ans = 0, x;
bool flag = true;
while(flag){
sort(nums.begin(), nums.end());
x = nums[nums.size()-1] - nums[0];
ans += x;
for(int i=0; i<nums.size()-1; +... | ALGO | 0.999979 | 5.494771 |
3496830b-82c0-435f-a0b5-ec2973c89387 | LoveLei0427/C-C- | 练习代码/虚函数/纯虚函数1.cpp | //д麯ĻΪ
//麯ֻڱ ʵ(ʵʵָ)
//ںIJԼֵ ָ
/*Base *test(Base* p)
{Base* pbase(nullptr);return pbase;}*/
//Ӧó ԲԲڽΡεܳ
#include<iostream>
#include<stdlib.h>
using namespace std;
#define PI 3.14
//
class Shape{
public:
virtual void Area() = 0;
virtual void Perimeter() = 0;
Shape(double x){ r = x; }
protected:
double r;
};
//Բ
... | TOOL | 0.918678 | 3.739698 |
e843636d-55a1-4033-952f-4571fa578c89 | Sarahhan-one/AdventCode2024 | advent15_2.cpp | #include <string.h>
#include <stdio.h>
#include <string>
#include <cassert>
#include <vector>
#include <set>
using namespace std;
char a[105][105];
int id[105][105];
int tmp[105][105];
pair<int, int> getDir(char c) {
if (c == '^') return {-1, 0};
if (c == 'v') return {1, 0};
if (c == '>') return {0, 1}... | ALGO | 0.999438 | 4.032195 |
8c8b73a7-fff1-4241-b5e8-fb3ba9208d8c | ut2310/codeforces | codeforces/2065/F.cpp | using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define MAXN 500005
#define ALPHABETSIZE 26
#define ff first
#define ss second
#define pii pair<long long,long long>
#define vi vector<long long>
#define vii vector<pair<long long,long long>>
vector<ll> adj[MAXN];
int main()
{
ios_base::sync_with_st... | ALGO | 0.99993 | 4.311331 |
31260f10-a9c6-4aaa-9ea2-b7a84fe2558b | Ashish-100-tiwari/DSA-C- | link-list-prac.cpp | #include<iostream>
using namespace std;
class node{
public:
int data;
node*next;
node(int val){
data=val;
next=NULL;
}
};
void insertatTail(node* &head,int val){
node*n=new node(val);
if(head==NULL){
head=n;
return ;
}
node*temp=head;
while(temp-... | ALGO | 0.999929 | 3.595907 |
fb4b78b7-4fd8-4f5c-ab89-d04177692023 | samiul2102013/CP | Code/28.5.24/A Round Decemal.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#ifdef LOKAL
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
const int N = 2e5 +5;
typedef pair<int,int> pii;
void TEST_CASES()
{
float x;cin>>x;
float c = floor(x);
if(x-c >= 0.5){
... | ALGO | 0.999535 | 3.836425 |
99e5f7ae-7734-4202-a798-d96dd2bdbdae | NanGongJin/Algorithm-Templates | Graph/Tree/LCA/dfsn.cpp | // LCA 最优解:DFS 序
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
// 下标从 1 开始,dfn[]:时间戳
int n, m, rt, dfn[N], st[N][20], cnt;
vector<int> e[N];
void dfs(int u, int fa) {
st[dfn[u] = ++cnt][0] = fa; // 存储父节点
for (int v : e[u])
if (v != fa) dfs(v, u);
}
#define M(x, y) (dfn[x] < dfn... | ALGO | 0.999949 | 4.597745 |
daa17e80-ceb1-4501-b234-fa2eed69bc05 | thepratholic/Competitive-Programming | Codeforces/practice problems/G_XOUR.cpp | // Choose cpp when the time
// limit will for sure give tle in pypy
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX
#define fastio ios::sync_with_stdio(false); cin.tie(0);
#define print(arr) for (auto it : arr){cout<<it<<" ";}cout<<endl;
#define len(arr) arr.size()
#define prin... | ALGO | 0.999743 | 4.661078 |
2ebf5877-ac1f-4eba-8f26-445db03c1ac3 | Prakash-cs20b028/DSAtutorials | InsertioninAvl.cpp | #include<iostream>
using namespace std;
struct node
{
int data;
int height; // if we use height as one extra data in node then
node* left; // it makes easier like whenever we add or rotate the node then we
node* right; // just update height so that we could easily find balance factor.
};
int Height... | ALGO | 0.999994 | 5.532007 |
55a35ec2-7db9-43e1-97be-acc077768d97 | arnirob/UVa_Solution | UVa_10281_Average_Speed.cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
char ch[100];
double speed;
int hr,mint,sec;
double ttl_dist=0,ttl_speed=0,ttl_time;
while(gets(ch))
{
sscanf(ch,"%d:%d:%d %lf",&hr,&mint,&sec,&speed);
int length=strlen(ch);
double cur_time=(hr*3600)+(mint*60)+s... | ALGO | 0.92395 | 3.603381 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.