uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
328b39c0-1865-4910-a8a5-0ed9a6c64ea5 | BUCEA/SWEs | Sources/libschemes/choice_scheme.cpp | /**
* @file choice_scheme.cpp
* @author Olivier Delestre <<EMAIL>> (2008)
* @author Christian Laguerre <<EMAIL>> (2012-2015)
* @version 1.06.00
* @date 2015-02-19
*
* @brief Choice of numerical scheme
* @details
* From the value of the corresponding parameter,
* calls the chosen numerical scheme.
*
* @copy... | ALGO | 0.999518 | 4.814764 |
d0494b26-42c8-477e-b317-49e4f36e607a | Azura-yuwi/Code | CSES/SortingSearching/DistinctNumbers.cpp | //CSES Sorting and Searching Set
//sort and search...
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
int main()
{
int n;
cin >> n;
int val[n];
for(int i = 0; i < n; i++)
{
cin >> val[i];
}
sort(val, val+n);
int to... | ALGO | 0.999883 | 4.07982 |
53e5198a-ae7d-441b-956b-62b2e7e56ed8 | MarcioAntusa/Beecrowd-Solutions | C++/1944.cpp | #include <iostream>
#include <stack>
std::stack<std::string> letras;
void preencherPilha()
{
letras.push("F");
letras.push("A");
letras.push("C");
letras.push("E");
}
int main()
{
int n = 0, cont = 0, res = 0;
std::string l[4];
std::stack<std::string> aux;
std::cin >> n;
preench... | ALGO | 0.999777 | 4.503753 |
4d930a82-67e4-46f9-8d4e-2e4b58ca91d9 | varenyamBakshi/cp-algorithms | segment tree/segment tree.cpp | #include<bits/stdc++.h>
using namespace std;
vector<int> stree;
void build(int v, int tl, int tr,vector<int> &arr){
if(tl==tr){
stree[v] = arr[tl];
return;
}
int tm = tl + (tr-tl)/2;
build(2*v, tl, tm, arr);
build(2*v+1, tm+1, tr, arr);
stree[v] = stree[2*v] + stree[2*v+1];
}
... | ALGO | 0.999963 | 3.931241 |
bfdf4cde-6657-4650-88a5-5e3277f58e9b | cjack/ACM | POJ/POJ2656.cpp | #include<iostream>
#include<fstream>
#include<stdio.h>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<string>
#include<cstdlib>
using namespace std;
#define SIZE 1000
int main()
{
int N;
int a, b;
int result = 0;
int unhappyDegree = 0;
while(1){
cin>>N;
if(N == 0) break;
result = 0;
unhappy... | ALGO | 0.998806 | 3.180443 |
1474af2b-8790-47a4-af35-3ab6fe54b5a4 | Bruno125/Estructura-de-datos-y-algoritmos | Otros/NumerosGrandes/NumerosGrandes/Bigint.cpp | #include "stdafx.h"
#include "Bigint.h"
CBigint::CBigint(void)
{
inicio = NULL;
final = NULL;
esPositivo=true;
}
CBigint::CBigint(char* numero){
inicio = NULL;
final = NULL;
esPositivo=true;
int nDigitos=strlen(numero);
if(nDigitos==0)
return;
if(nDigitos==1 && numero[0]=='-')
return;
int pos=0;
if(... | ALGO | 0.986599 | 3.598442 |
dd89b97e-bd83-4770-8745-3a522b9bd1ed | thegamer1907/Code_Analysis | contest/1542594570.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long lint; typedef pair<int, int> ii;
const int MOD = 1'000'000'007, MOD2 = 1'000'000'009;
const int INF = 0x3f3f3f3f; const lint BINF = 0x3f3f3f3f3f3f3f3fLL;
string s;
int n;
string t[105];
int solve(){
cin >> s;
cin >> n;
for(int i=0;i<n;i++) cin >> t[i... | ALGO | 0.999967 | 4.130194 |
f72bfd23-9dc7-4100-a3ed-93dd183ef6be | m4rcus06/CP | usaco/Gold/December2019/A.cpp | #include <bits/stdc++.h>
using namespace std;
using lli = long long;
#ifdef LOCAL
#include </home/marcus06/CP/Library/debug.h>
#else
#define debug(...)
#endif
/*How to use:
Tvector <int, 2> g(n); //graph
Tvector <int, 3> f(n, k, 2) = f[n][k][2]
*/
template <class Tp, int D = 1>
struct Tvector : public vector<Tve... | ALGO | 0.999693 | 4.12078 |
4eb21a35-48ed-4881-b92b-64c307e3dac1 | FelipeSempertegui/FEM_renderer | externalLibraries/eigen-3.3.7/doc/examples/TutorialLinAlgComputeTwice.cpp | #include <iostream>
#include <Eigen/Dense>
using namespace std;
using namespace Eigen;
int main()
{
Matrix2f A, b;
LLT<Matrix2f> llt;
A << 2, -1, -1, 3;
b << 1, 2, 3, 1;
cout << "Here is the matrix A:\n" << A << endl;
cout << "Here is the right hand side b:\n" << b << endl;
cout << "Computing LLT... | ALGO | 0.999962 | 3.145425 |
320dc870-4f10-42bb-a260-a28f055b538a | sankalp0412/C_Coding | Recursion/Kth permutation sequence Leetcode/code.cpp | //first approcah is the brute force approcah
//where we will calculate all the permutaions and store in a daata strucure
//and sort it the k sequence will be at k-1 index
//TC of brute force: (n!) * N * O(n!logn!) to store into ds
// in interiew alwas approach with the naive approach first
//this is important please... | ALGO | 0.999865 | 4.932612 |
c0c91bce-e8ca-43ab-8171-e9b14ed1ac7a | lawy623/Algorithm_Interview_Prep | Algo/Leetcode/029DivideTwoInteger.cpp | //1. Remember to avoid bit overflow(only one case. Every time, we do not only deduct divisor, but multiple 2.
class Solution {
public:
int divide(int dividend, int divisor) {
if(dividend == INT_MIN && divisor == -1) return INT_MAX;
long long a = dividend >= 0 ? dividend : -(long long... | ALGO | 0.999975 | 5.946459 |
7e30553d-71f6-4477-8183-36bcd484c685 | Ufguff/Algotithms | 20/main.cpp | #include <iostream>
#include <vector>
#include <chrono>
#include <algorithm>
#include <random>
using namespace std;
const int RUN = 32;
const unsigned long long n = 1e6;
void insertionSort(int arr[], int left, int right)
{
for (int i = left + 1; i <= right; i++) {
int temp = arr[i];
int j = i - 1;... | ALGO | 0.998907 | 5.341405 |
6f7defe5-a607-4add-a0a0-a59b57af860b | saumyasrivastava08/Important_Coding_Problems | Codeforces/Practice/C++/B-LoveSong.cpp | //https://codeforces.com/contest/1539/problem/B
#include<bits/stdc++.h>
using namespace std;
void solve(){
int n,k;
cin>>n>>k;
string s;
cin>>s;
map<char,int> m;
int x='a';
for(int i=1;i<=26;i++){
m[x]=i;
x++;
}
int pref[n+1];
auto it=m.find(s[0]);
pref[... | ALGO | 0.9999 | 4.31766 |
0dbc6fc5-21cc-4627-b920-f5f0477b8929 | zhihongzeng2002/cppcoding | elements/misc.cpp | #include "misc.h"
#include <stack>
#include "utilities.hpp"
#include <stdexcept>
#include <set>
#include <cstring>
#include <climits>
#include <list>
#include <numeric>
Misc::Misc()
{
}
bool Misc::checkPushPop(const vector<int> &pushV, const vector<int> &popV) {
int pushCurr=0, popCurr=0;
stack<int> buff;
... | ALGO | 0.998985 | 3.29855 |
b653ef0c-e5a9-4f20-a965-0ea6927137cd | ishandutta2007/codeforces | marckess/normal/1697/B.cpp | // Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % abs(k)) + abs(k) ) % abs(k))
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forr(i,a,b) for (int i = int(a); i <= int(b); i++)
#define all(v) v.begin(), ... | ALGO | 0.999907 | 4.21734 |
b93767a3-af92-4be8-a105-245ce43212b6 | qqq26/Nuzu | src/video_core/renderer_vulkan/vk_query_cache.cpp | #include <cstddef>
#include <limits>
#include <map>
#include <memory>
#include <span>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
#include "common/bit_util.h"
#include "common/common_types.h"
#include "video_core/engines/draw_manager.h"
#include "video_core/host1x/gpu_device_me... | TOOL | 0.889686 | 3.18898 |
d4305b5c-e685-4ae1-8634-2aed67e35725 | ratnesh-maurya/my-coding-stuff | Hard/Largest Sum Cycle/largest-sum-cycle.cpp | //{ Driver Code Starts
//Initial Template for C++
#include<bits/stdc++.h>
using namespace std;
// } Driver Code Ends
//User function Template for C++
class Solution
{
public:
long long largestcycle=-1;
void DFS(int node,vector<int>& Edge,bool visited[],bool pathvisited[])
{
visited[node]=true;
path... | ALGO | 0.999482 | 5.532048 |
1ca5df0f-1883-444a-b4c5-eb55a12d7a39 | s10e-g/algorithm_exercise | acm/usaco/3.1/6-Stamps/stamps.cpp | /*
ID: shadowm6
PROG: stamps
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
using namespace std;
int main()
{
ifstream fin("stamps.in");
ofstream fout("stamps.out");
int k, n, max_val = 0;
fin>>k>>n;
vector<int> val(n);
for(int i = 0; i < n; i++){
... | ALGO | 0.999874 | 3.539151 |
e78cf4f1-af9f-4814-a8a2-e44948cb9e52 | sh0g02/atCoder_introduction | abc093_b.cpp | #include <iostream>
using namespace std;
int main() {
int a, b, k;
cin >> a >> b >> k;
for (int i = a; i <= min(b, a + k - 1); ++i) {
// 0からのループではなく、始点をaにする
// bと、kの和がどちらか近い方までループ
std::cout << i << std::endl;
}
for (int i = max(b - k + 1, a + k); i <= b; ++i) {
std::... | ALGO | 0.999915 | 3.167158 |
e36bef49-8f18-4c6c-8ead-e4f889d7ee47 | sarvex/leetcode-ada | lcp/LCP 70. 沙地治理/Solution.cpp | class Solution {
public:
vector<vector<int>> sandyLandManagement(int size) {
vector<vector<int>> ans;
ans.push_back({1, 1});
for (int i = size, k = 0; i > 1; --i, k = (k + 1) % 4) {
if (k == 0) {
for (int j = 1; j < i << 1; j += 2) {
ans.push_b... | ALGO | 0.999925 | 5.34564 |
23a70017-9955-409b-8790-14bed2ffc661 | mddirga/emarket-frontend-flutter | windows/runner/utils.cpp | #include "utils.h"
#include <flutter_windows.h>
#include <io.h>
#include <stdio.h>
#include <windows.h>
#include <iostream>
void CreateAndAttachConsole() {
if (::AllocConsole()) {
FILE *unused;
if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
_dup2(_fileno(stdout), 1);
}
if (freopen_s(&unuse... | TOOL | 0.9988 | 6.76073 |
aa75c20a-f6ff-4c43-9169-f717a312e31f | meowmeow321/cp-snippets | some good fuckin snippets/USACO-master/Other Implementations/04 - Sorting and Searching/Interval Cover (4.1).cpp | /**
* Description: example of greedy algorithm
* Source: Own
* Verification: https://open.kattis.com/problems/intervalcover
* actually, you need to account for A=B and add epsilons but w/e
*/
vi solve(double A, double B, vector<pair<pd,int>> in) { // cover [A,B] with intervals from in
pair<double,int> mx =... | ALGO | 0.999978 | 4.925708 |
dedcfd90-bf5d-42c8-8b22-b15bc1ce08ef | fvan-wij/openFrameworks_experiments | marchingSquares/src/ofApp.cpp | #include "ofApp.hpp"
#include "ofEvents.h"
#include "ofGraphics.h"
#include "ofUtils.h"
#include <ostream>
//--------------------------------------------------------------
void ofApp::initializeFieldVector()
{
kinect.update();
RES = 5;
COLS = kinect.getWidth() / RES + 1;
ROWS = kinect.getHeight() / RES + 1;
ZOFFS... | TOOL | 0.953037 | 5.159272 |
a44cf268-7ad1-46c1-9225-beaa57afa343 | saim-x/Leet_Code | 1411-convert-binary-number-in-a-linked-list-to-integer/convert-binary-number-in-a-linked-list-to-integer.cpp | /**
* 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) {}
* };
*/
class Solution {
public:
int convert(vector<in... | ALGO | 0.99997 | 5.404294 |
b95f66f0-bd27-4322-8290-2876c0c51604 | CC-MNNIT/2021-22-Classes | CompetitiveProgramming/2021_08_15_CPClass-4/Codes/Kadane_algo.cpp | #include <bits/stdc++.h>
using namespace std;
int kadane_algo(vector<int>& A) {
int curr_sum = A[0] , max_sum = A[0];
/*
curr_sum -> suff[i-1]
max_sum -> fun(i-1)
*/
for(int i = 1 ; i < A.size() ; i++) {
curr_sum = max(curr_sum + A[i] , A[i]);
max_sum = max(max_sum , cur... | ALGO | 0.999946 | 5.071103 |
04079ec1-20c7-4b2b-889b-25c89ce076d3 | AhnSangHee/Algorithm | Algorithm/Basic/8393.cpp | // 합
// 8393.cpp
// Algorithm
//
// Created by 안상희 on 2023/04/17.
//
#include <iostream>
using namespace std;
int n, sum;
int main() {
cin.tie(0);
cout.tie(0);
std::ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++) {
sum += i;
}
cout << sum << '\n';
... | ALGO | 0.999619 | 5.4315 |
2a24ff59-aff0-485b-ae1a-7c53dc8ef540 | hieu-ln/IT82-09 | CodeC3/HanTin_C3_b1.cpp | // Bai 1, chuong 3: XEP THU TU, TIM KIEM
#include<stdio.h>
#include<iostream>
#include<ctime>
#include<iomanip>
using namespace std;
# define MAX 2000
// 1.1
int a[MAX];
int n;
//0.a Nhap
void init(int a[], int &n){
cout << "Nhap vao so luong phan tu cua danh sach: ";
cin >> n;
for (int i = 0; i < n- 1; i ++){
a[... | ALGO | 0.999579 | 3.158489 |
1448baf4-f402-4799-97b1-fe349c2b58ed | sh-sho1kat/CODEFORCES | Educational Codeforces Round 144 (Rated for Div. 2)/B_Asterisk_Minor_Template.cpp | ///********************** بِسْمِ ٱللَّهِ ٱلرَّحْمَـٰنِ ٱلرَّحِيمِ **********************///
/**
* author: Shefat Hossen Shoikat
* date : 2023-03-07 05:37:52
**/
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define mod 1000000... | ALGO | 0.999994 | 4.654009 |
287022b2-bc35-4a23-b033-4151e48d91e0 | Wlzzzz-del/leetcode_property | 1305_getAllElements.cpp | // leetcode 1305 两颗二叉搜索树中的所有元素
// https://leetcode.cn/problems/all-elements-in-two-binary-search-trees/
#include <iostream>
#include <vector>
#include <algorithm>
// definition of a binary tree node
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode() : val(0), left(nullptr), right(nu... | ALGO | 0.999981 | 6.118086 |
6427e976-09aa-4d7a-9bd5-c1402519849c | FeibHwang/OJ-Leetcode | Code/9_Palindrome_Number.cpp | /*
Determine whether an integer is a palindrome. Do this without extra space.
click to show spoilers.
Some hints:
Could negative integers be palindromes? (ie, -1)
If you are thinking of converting the integer to string, note the restriction of using extra space.
You could also try reversing an integer. However, if ... | ALGO | 0.999924 | 6.366294 |
a0091ed4-d874-40dd-8d9c-443e497b46f2 | ws333666/HaiZei-OJ | 81.cpp | /*************************************************************************
> File Name: 81.cpp
> Author:
> Mail:
> Created Time: 2020年04月01日 星期三 19时41分55秒
************************************************************************/
#include <iostream>
#include <queue>
using namespace std;
struct node {
int x... | ALGO | 0.999882 | 3.41631 |
d76d1409-1a7f-41c9-b8ca-a923b940a6c6 | ishandutta2007/codeforces | gs12117/normal/271/E.cpp | #include<stdio.h>
int a[100100];
int n,m;
int b[100100];
int bn;
long long int ans;
int gcd(int x,int y){
if(y==0)return x;
return gcd(y,x%y);
}
int main(){
int i,tgcd;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
a[i]--;
}
tgcd=a[0];
while(tgcd%2==0)tgcd/=2;
for(i=1;i<n;i++){
tgcd=gcd(a[i],... | ALGO | 0.999975 | 3.083711 |
c264dd11-0b5c-443e-b254-63285c161804 | imakshaysoni/LeetCode | 0547-number-of-provinces/0547-number-of-provinces.cpp | class Solution {
public:
int findCircleNum(vector<vector<int>>& isConnected) {
int cities=isConnected.size();
vector<vector<int>> adj(cities+1,vector<int> (cities+1,0));
for(int i=0;i<cities;i++){
for(int j=0;j<cities;j++){
if(i!=j and isConnected[i][j]==1){
... | ALGO | 0.99998 | 5.914213 |
e73df6c4-1da9-4934-8550-26414026871e | Amir-Gaifullin/Algoritm_GaifullinAR | homework_09-03-21/task1.ex3.18.cpp | #include <iostream>
using namespace std;
struct Node
{
int data;
Node* next;
Node* prev;
};
struct List
{
Node* pHead;
Node* pLast;
List()
{
pHead = NULL;
pLast = NULL;
}
void add(int item){
Node * head = pHead;
int i = 0;
bool flag = true;... | ALGO | 0.998698 | 4.475605 |
77bce0a0-e22f-4cf9-8435-834c891ca7c3 | Eli0ttt/Code-Practice | 两数相加.cpp | //#include<iostream>
//#include<cmath>
//#include<string.h>
//using namespace std;
//struct ListNode {
// int val;
// ListNode* next;
//};
//ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
// ListNode* l3 = new ListNode;
// l3->next = NULL;
// int flag = 0;
// l3->val = l1->val + l2->val;
// if (l3->val > 9) {
//... | ALGO | 0.999367 | 4.411782 |
a28fddec-9580-40bd-a601-041f0212509e | sahilduhan/pepcoding_youtube | binary_tree_pepcoding/path_root_to_node.cpp | #include <bits/stdc++.h>
using namespace std;
class binary_tree_node
{
public:
int data;
binary_tree_node *left;
binary_tree_node *right;
binary_tree_node(int data)
{
this->data = data;
left = right = NULL;
}
};
bool is_found(binary_tree_node *root, int data)
{
vector<binary_... | ALGO | 0.999939 | 5.18028 |
9d68b05d-16b1-43e5-b28e-f5c020936da3 | ishandutta2007/codeforces | tlewpdus/normal/1179/C.cpp | #include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
struct query {
int t, b, c;
};
int n, m, q;
int arr[300100], brr[300100];... | ALGO | 0.999997 | 4.319971 |
90a512ef-0782-4369-a2ae-48496e814124 | arthas1123/cpp-practice | 209_minSubArr.cpp | #include <vector>
#include <algorithm> // sort
#include <iostream>
using namespace std;
class Solution
{
public:
int minSubArrayLen(int target, vector<int> &nums)
{
sort(nums.begin(), nums.end(), [](int a, int b)
{ return a > b; });
int ans = nums[0];
int count = 1;
... | ALGO | 0.999946 | 6.075836 |
1bb08e55-3243-48c8-b475-01ba424c5477 | LSBUGPG/2010-2011 | StudentFiles/callaghan/Week 3 Exercise/Week 3 Exercise/Fight Club.cpp | #include <conio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
bool wrong_answer(int have, const char * looking_for)
{
bool wrong = (strchr(looking_for, have) == NULL);
if (wrong) {
_cputs(
"\n"
"Choose already! \n"
"\n");
}
return wrong;
}
int roll(int sides)
{
return (rand() % sides) +... | TOOL | 0.893846 | 3.64499 |
d829c3c8-6671-4ffb-9930-4e23ce30689f | luisza/dfva_c | dfva_c/crypto.cpp | #include <openssl/sha.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <openssl/hmac.h>
#include <openssl/evp.h>
#include <openssl/bio.h>
#include <openssl/buffer.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>
#include <openssl/rsa.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#incl... | TOOL | 0.896562 | 6.608172 |
078707b6-7be7-4529-b128-9a4078dc9b06 | MDGSF/JustCoding | sword_to_offer/CodingInterviewChinese2/21_ReorderArray/ReorderArray.cpp | //==================================================================
// ָOfferԹپͱ⡷
// ߣκ
//==================================================================
// 21˳ʹλżǰ
// Ŀһ飬ʵһֵ˳ʹ
// λǰ벿֣żλĺ벿֡
#include <cstdio>
void Reorder(int *pData, unsigned int length, bool (*func)(int));
bool isEven(int n);
// ===============... | ALGO | 0.999698 | 4.823879 |
b0d9246c-f4ce-444e-b341-eac5fac820d5 | cyndel1/client-tools | src/engine/shared/library/sharedMath/src/shared/core/RangeLoop.cpp | #include "sharedMath/FirstSharedMath.h"
#include "sharedMath/RangeLoop.h"
#include "sharedFoundation/ConfigFile.h"
#include "sharedMath/ConfigSharedMath.h"
// ----------
float RangeLoop::clip ( float x )
{
return x - (float)floor(x);
}
// distance you have to go in the positive direction to get from A to B
float ... | TOOL | 0.975866 | 5.930361 |
e9cf7cff-abc0-45aa-84c4-d25ce894b433 | danishshariff/problem_solving_2 | Difficulty: Easy/Find XOR of numbers from L to R./find-xor-of-numbers-from-l-to-r..cpp | // User function Template for C++
class Solution {
public:
int func(int n){
if(n%4==1)return 1;
else if(n%4==2) return n+1;
else if(n%4==3) return 0;
else return n;
}
int findXOR(int l, int r) {
// complete the function here
return func(l-1)^func(r);
}
}; | ALGO | 0.999981 | 4.81886 |
969cc6dd-65a4-4e49-aee4-4c895994703b | NasiriMohsen/CPP-Codes | C++/011-Integers-sub.cpp | #include <iostream>
using namespace std;
int main() {
int a = 5;
int b = 10;
int result1;
int result2;
result1 = a - b;
result2 = b - a;
cout << "The result of a - b is: " << result1 << endl;
cout << "The result of b - a is: " << result2 << endl;
return 0;
} | ALGO | 0.999823 | 4.086957 |
283fa677-a8ab-4145-9443-fdaa4ee52acd | arjundevireddy/DataStructuresAndAlgorithms | Data Structures/C++/Graph/graph.cpp | /*
Name: Arjun Devireddy
Coding 07
Purpose: This program creates an graph and functions
to add and find vertices and edges of the graph
*/
#include "graph.h"
Graph::Graph(){
eCount = 0;
vCount = 0;
}
bool Graph::createVertex(int id){
bool createdV = false;
Node temp = {id, false};
if(graph.... | ALGO | 0.99409 | 4.934165 |
f3cab673-bcff-4bf5-ab97-cd43e1a4e21a | jychstar/NanoDegreeProject | CarND2/p5_mpc/src/Eigen-3.3/lapack/cholesky.cpp | #include "lapack_common.h"
#include <Eigen/Cholesky>
// POTRF computes the Cholesky factorization of a real symmetric positive definite matrix A.
EIGEN_LAPACK_FUNC(potrf,(char* uplo, int *n, RealScalar *pa, int *lda, int *info))
{
*info = 0;
if(UPLO(*uplo)==INVALID) *info = -1;
else if(*n<0) ... | ALGO | 0.995201 | 6.004565 |
d49b4421-0d46-4c7f-a22e-ec2e47142637 | lemoneid/1.do-exercises | Algorithm/Nowcoder/cd-174.cpp | /*************************************************************************
> File Name: cd-174.cpp
> Author: yanzhiwei
> Mail: <EMAIL>
> Created Time: 2020年11月22日 星期日 21时23分34秒
************************************************************************/
#include <iostream>
#include <algorithm>
#include <cstdio>
#in... | ALGO | 0.99992 | 4.253242 |
62d66fe1-a81f-4bfb-b190-11bed989316d | franquium/ie0217 | Previos/Previo_1/Sesion_3/punterosYFunciones3.cpp | #include <iostream>
using namespace std;
// definicion de func para swapear valores
void swap(int* n1, int* n2) {
int temp;
temp = *n1;
*n1 = *n2;
*n2 = temp;
}
int main() {
// inicializando variables
int a = 1, b = 2;
cout << "Antes del swapeo" << endl;
cout << "a = " << a << endl;
... | ALGO | 0.997705 | 4.779174 |
d89ec59a-511d-4dc5-a827-056e750e9133 | Sharif1000/XPSC-Batch-3 | Week05/Weekly Tricks/Binary Search/Lower Bound.cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n; cin>>n;
vector<int>v(n);
for(int i = 0; i < n; i++) cin>>v[i];
int x; cin>>x;
auto it = lower_bound(v.begin(), v.end(), x);
int idx = it - v.begin();
cout<<idx;
return 0;
}
| ALGO | 0.999572 | 5.477196 |
5df60f8f-5af3-4594-8884-443a8c16fd87 | reo0105/atcoder | contest/2023_09_09_beginner/B.cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
string s;
s.push_back('1');
for (int i = 1; i <= n; i++) {
int j;
for (j = 1; j < 10; j++) {
if (n % j == 0 && i % (n/j) == 0) {
s.push_back('0' + j);
break;
... | ALGO | 0.999908 | 4.579054 |
4704ed2b-f284-42f0-b872-4db3d519ddb2 | sraihan73/Lucene- | analysis/stempel/src/java/org/egothor/stemmer/Gener.cpp | using namespace std;
#include "Gener.h"
#include "Cell.h"
#include "Row.h"
#include "Trie.h"
namespace org::egothor::stemmer
{
Gener::Gener() {}
shared_ptr<Trie> Gener::optimize(shared_ptr<Trie> orig)
{
deque<std::shared_ptr<std::wstring>> &cmds = orig->cmds;
deque<std::shared_ptr<Row>> rows = deque<std::shared... | ALGO | 0.995766 | 5.497086 |
d9b63f66-b542-448d-afd9-61c6273346e1 | Nghiabe/Lab3-4-5-6-7 | lab3-main/lab3-main/windows/runner/utils.cpp | #include "utils.h"
#include <flutter_windows.h>
#include <io.h>
#include <stdio.h>
#include <windows.h>
#include <iostream>
void CreateAndAttachConsole() {
if (::AllocConsole()) {
FILE *unused;
if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
_dup2(_fileno(stdout), 1);
}
if (freopen_s(&unuse... | TOOL | 0.994788 | 6.76073 |
115424ad-0ae5-4f07-9dee-8d5e135d996e | DeathGodBXX/learn_new_cpp | LeetCode/DynamicAsg/DiffPath/differentPath.cpp | //m*n个格子,从左上方到右下方有多种不同的路径,只能向右走和向下走
#include <vector>
using std::vector;
class Solution
{
public:
//组合数学
//1.从(0,0)到(m-1,n-1),其中路径长度是m+n-2,选取m-1种向下走的方式,组合数(m-1,m+n-2)
// int uniquePaths(int m, int n) {
// long long int ans=1;
// for(int x=n,y=1;y<m;x++,y++){
// ans = ans*x/y;
... | ALGO | 0.999981 | 4.558722 |
6e1cfcd2-ae4c-4b9b-a776-8a5a46869061 | pfmephisto/ReUseX | src/types/Geometry/PointClouds_filter.cpp | #include "PointCloud.hh"
#include "PointClouds.hh"
#include "core/spdmon.hh"
#include <spdlog/spdlog.h>
#include <spdlog/stopwatch.h>
#include <vector>
namespace ReUseX {
template <typename T>
PointClouds<T> PointClouds<T>::filter(std::uint32_t value) {
// Only keep highest confidence
//////////////////////////... | TOOL | 0.914274 | 6.171197 |
ac93f45e-f025-4384-8288-b584d58651dc | krotrn/CPP | Queue/Problem/ReorderQueue.cpp | // Interleave the first half of the queue with the second half
// Use only one stack
// even
#include<iostream>
#include<queue>
#include<stack>
using namespace std;
void interleaave(queue<int> &q){
stack<int> s;
int n = q.size();
// 1 2 3 4 5 6 7 8
for(int i=0; i<n/2; i++){ // queue -> stack half
... | ALGO | 0.999913 | 4.109042 |
20e6c871-58e0-4c04-9feb-a09b35910ee0 | rbalaji7/practice-swu | cplusplus/odd_even.cpp | #include<iostream>
#include<thread>
#include<mutex>
#include<condition_variable>
using namespace std;
mutex mtx;
condition_variable cv;
int number;
int count = 1;
int iteration = 0;
void printOddNumbers(){
while(count<number){
unique_lock<mutex> lock(mtx);
cv.wait(lock, []{return (count % 2 == ... | ALGO | 0.991911 | 4.904376 |
578acfd3-3da4-4067-86f2-faf01f392a9a | leokang123/Algorithm | 2.2.시뮬레이션/truck_revise.cpp | #include <bits/stdc++.h>
using namespace std;
int N,W,L;
int arr[1000];
int bridge[100000];
int sPoint;
void showBridge(void) {
for(int i = sPoint ; i < sPoint + W ; i++ ){
cout << bridge[i] <<' ' ;
}
cout << '\n';
}
int main(void){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin ... | ALGO | 0.999923 | 3.966049 |
00861488-4237-4cf8-a3e0-3eb59d7d193c | AdityaChirravuri/CompetitiveProgramming | HackerRank/Problem Solving/Algorithms/GraphTheory/Prims.cpp | #include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 5001
#define Max INT_MAX
#define P pair<int, int>
//global variables
int n, e, src;
vector<P>adj[MAX];
/*
n -> number of vertices
e -> number of edges
src -> source vertex to start
adj -> to repre... | ALGO | 0.999852 | 3.711111 |
ffba607b-d72b-4368-8ff1-674d6f489c79 | DrZhang818/my-first-project | Problems/Codeforces/Contests/Round1024/B.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> PII;
typedef unsigned long long ull;
const int inf = 1000000000;
void solve() {
int n;
cin >> n;
vector<int> a(n + 1);
for(int i = 1; i <= n; i++) {
int x;
cin >> x;
a[i]... | ALGO | 0.999874 | 4.777659 |
d2eaad14-e8ac-4413-a3ee-fd4e52746db1 | 0x1Shub/Data-Structures-And-Algorithms | Striver DSA Sheet/15-Graphs/15.2-Problem on BFS_DFS/01_Number_of_provinces.cpp | #include <bits/stdc++.h>
using namespace std;
class Solution
{
private:
void dfs(int node, vector<int> adjLst[], int vis[])
{
vis[node] = 1;
for (auto it : adjLst[node])
{
if (!vis[it])
{
dfs(it, adjLst, vis);
}
}
}
publi... | ALGO | 0.99998 | 5.813639 |
f880ec27-73e8-4418-95d0-e285419cb7f3 | suicidepool/DSA-Problem-Solve | c++/Array/Problems/Easy/moveZerosToEnd.cpp | // Move all the zeros to the end of an array
#include <iostream>
using namespace std;
void moveZerosToEnd(int arr[], int n){
//better approach - time complexity O(2n)
/* int zeroCount = 0;
int j = 0;
for(int i = 0; i < n; i++){
if(arr[i] == 0){
zeroCount++;
}
else{
... | ALGO | 0.999658 | 5.217682 |
69b8e866-ddd4-4b13-ad1c-8fd8eb9f6bf3 | akotadi/Competitive-Programming | Contest/Club Ranking/Cuarentena2020/3/D.cpp | #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
using namespace std;
__attribute__((constructor)) void _() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
s... | ALGO | 0.999806 | 4.2555 |
33604155-97a3-4e98-949b-6c2eba6deebb | Jleeblanch/device_motorola_athene | gps/core/ContextBase.cpp | #define LOG_NDEBUG 0
#define LOG_TAG "LocSvc_CtxBase"
#include <dlfcn.h>
#include <cutils/sched_policy.h>
#include <unistd.h>
#include <ContextBase.h>
#include <msg_q.h>
#include <loc_target.h>
#include <platform_lib_includes.h>
#include <loc_log.h>
namespace loc_core {
loc_gps_cfg_s_type ContextBase::mGps_conf {};
... | CONFIG | 0.860243 | 6.22845 |
b0cbef30-6e76-4cca-a732-c6c69aace468 | IvanFilipov/FMI-DSA | algorithms/graph_algorithms/minimal_spanning_tree/kruskal/kruskal_mst.cpp | /*******************************************************************************
* This file is part of the "Data structures and algorithms" course. FMI 2018/19
*******************************************************************************/
/**
* @file kruskal_mst.cpp
* @author Ivan Filipov
* @date 01.2019
... | ALGO | 0.999955 | 5.193341 |
12d01a5e-49c4-4b76-9502-a5819946132c | Limajla143/CPP | Prog2/minloc.cpp | // Problem ID: 1031011
// Name: Al Jamil L. Arazas (ID: 2012-1-0712)
// Honor Code: I have not given nor received any unauthorized help in this work.
#include <iostream>
using namespace std;
int getMinLoc(int x[], unsigned int n)
{
if (n == 0)
return -1;
else if (n == 1)
return 0;
else if (x[getMinLoc... | ALGO | 0.999927 | 4.679657 |
533c79af-2532-43db-8a82-8fae9758353a | xyzyzl/compprog | probs/teamscode/2021/real/e.cpp | #include <bits/stdc++.h>
using namespace std;
int n, m, gr[1005][1005];
long long dp[1005][1005];
const int MOD = 1e9+7;
int main()
{
cin >> n >> m;
for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin >> gr[i][j];
dp[0][0] = (gr[0][0] == 0);
for(int i = 0; i < n; i++) for(int j = 0; j < m; j++)
{
if(gr[i... | ALGO | 0.99997 | 4.69721 |
ec595bd9-06ba-4e0c-ab05-191c9275fc4c | WindriderQc/Marlin-2.1.1.EG-YB | buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/variant.cpp | #include "pins_arduino.h"
#ifdef __cplusplus
extern "C" {
#endif
// Digital PinName array
const PinName digitalPin[] = {
PA_0, // Digital pin 0
PA_1, // Digital pin 1
PA_2, // Digital pin 2
PA_3, // Digital pin 3
PA_4, // Digital pin 4
PA_5, // Digital pin 5
PA_6, // Digital pin 6
PA_7, // Dig... | CONFIG | 0.929981 | 6.350003 |
b9edd320-7d2a-444c-ae2c-c5b809af1703 | ishandutta2007/codeforces | alexandr_ts/normal/919/B.cpp | #define _CRT_SECURE_NO_WARNINGS
#include <memory>
#include <cstdio>
#include <type_traits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <cassert>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <unor... | ALGO | 0.999546 | 4.272192 |
31b92c51-b74e-4fa2-a607-919b1a3706af | TheNitesWhoSay/MiniViews | source/IcuLib/propsvec.cpp | #include <stdlib.h>
#include "unicode/utypes.h"
#include "cmemory.h"
#include "utrie.h"
#include "utrie2.h"
#include "uarrsort.h"
#include "propsvec.h"
#include "uassert.h"
struct UPropsVectors {
uint32_t *v;
int32_t columns; /* number of columns, plus two for start & limit values */
int32_t maxRows;
... | TOOL | 0.99523 | 6.298489 |
ae7f2f58-4c73-4915-91ee-dd65aadca9cc | sarvex/leetcode-scala | solution/2300-2399/2396.Strictly Palindromic Number/Solution.cpp | class Solution {
public:
bool isStrictlyPalindromic(int n) {
return false;
}
}; | ALGO | 0.998739 | 5.627177 |
3479c39b-1d36-4940-9816-39bf1bc5607a | ShubhamSingh1384/code-with-SSR | day2/impsol1.cpp | #include<iostream>
using namespace std;
int main(){
int n,count = 0;
cin>>n;
while(n!=0){
if(n&1){
count++;
}
n = n>>1;
}
cout<<count;
} | ALGO | 0.99989 | 4.176358 |
9669497d-25c1-43b4-9de2-8f1d3aad0622 | renbaoshuo/OI-codes | Luogu/P4445/P4445.cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, a[100005];
long long ans = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 1; i < n; i++) {
ans += max(a[i], a[i - 1]);
}
cout << ans << endl;
return 0;
}
| ALGO | 0.999953 | 4.265476 |
83c0eb52-16a3-4cc0-b9ed-99b78ba647f8 | sarabjeetsingh1708/coding | c++/sortedsquare.cpp | #include<iostream>
#include<vector>
#include<algorithm> // Include the algorithm header for reverse function
using namespace std;
vector<int> sortedSquares(vector<int>& a) {
int n = a.size(), i = 0, j = n - 1;
vector<int> ans(n); // Initialize ans vector with the correct size
int k = n - 1; // Index for fi... | ALGO | 0.999941 | 5.346469 |
c83c81cb-74fe-408f-b790-7c0d290d44de | wataken44/topcoder | work/src/BricksN.cpp | #include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <ut... | ALGO | 0.999946 | 4.46245 |
e33f8425-850d-4757-adec-d8fcec522eb8 | 846754497THK/ACM-tools-and-skills | 程序板子/Algorithm/Halfhull.cpp | /*
凸包+分治
分上下凸壳维护
*/
/*
Problem:给出一个直线集Ax+B,现在给出一些查询,每次查询一条直线Cx+D,
问与直线集中直线交点最大的x是多少
Solution:我们得到交点x=-(B-D)/(A-C),我们对所有的A和C取负,
那么答案就是求点(-Cq,Dq)到点集(-Ai,Bi)的最大斜率,
我们按照横纵坐标排序,维护上左凸壳和下右凸壳,询问点到凸壳的斜率是一个单峰函数,
可以三分找到最大斜率的位置,也可以二分找到点到mid和mid+1大小状况突变的位置
*/
// 三分
#include <bits/stdc++.h>
using name... | ALGO | 0.999954 | 4.565623 |
575fa096-502a-4c00-902d-571ba0355c18 | Omer283/CPSubmissions | Codeforces/Codeforces Round #486 (Div. 3) - (F) Rain and Umbrellas.cpp | #define fast ios::sync_with_stdio(false); cin.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define mp make_pair
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <num... | ALGO | 0.999799 | 4.265564 |
3adbc495-f14d-446b-9eea-01b9cc872b9c | refainHub/ACM-ICPC | 做题记录/模板/数学/格雷码.cpp | vector<int> Gray_Create(int n)
{
vector<int> res;
res.clear();
for(int i=0;i<(1<<n);i++)
{
res.push_back(i^(i>>1));
}
return res;
} | ALGO | 0.998973 | 3.74013 |
f8203803-0798-4813-82fe-c649b9847a9c | AtharvaChivate/CrackYourPlacement | ExcelSheetColumnNumber.cpp | #include <iostream>
#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
int titleToNumber(string columnTitle)
{
int ans = 0;
for (int i = 0; i < columnTitle.length(); i++)
{
// Convert character to its corresponding position (1-based)
int value... | ALGO | 0.999407 | 6.306139 |
54d624a0-e9f3-4250-ba8a-312b4a321849 | Aarav562/Data-Structures | Stack/UsingLL.cpp | #include <iostream>
using namespace std;
class Node{
public:
int data;
Node* next;
};
class Stack{
private:
Node* top;
public:
Stack();
~Stack();
void push(int x);
int pop();
int peek(int index);
int isEmpty();
int isFull();
int stackTop();
};
Stack::Stack() {
top =... | ALGO | 0.998846 | 4.7265 |
522cc21b-972b-45b7-9fc0-b89c692b7a80 | kabraneel/Competitive-Programming | Atcoder/abc266/C.cpp | // na ho paega humse
// nai_aati_coding
// i love PD
// Motivation when feeling low : http://bitly.com/98K8eH
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
#define int long long
#ifdef KABRANEEL
#define LOCAL
#include "/home/kabraneel/coding/debug.h"
#else
#define debug(x...)
#define debugln(x...)
#e... | ALGO | 0.999829 | 4.237267 |
c8d124e8-5f9b-4fd2-8b74-6dc148f82182 | imkeshav1272/Basic-C-Program | pattern/oddnofiptriangle.cpp | #include <iostream>
using namespace std;
int main()
{
int n;
cout << "enter n : ";
cin >> n;
int a;
for (int i = 1; i <= n; i++)
{
int a = 1;
for (int j = 1; j <= n+1-i; j++)
// for (int j = 1; j <= i; j++)
{
cout << a << " ";
a += 2;
... | ALGO | 0.999536 | 3.458168 |
baefd3bc-a1a4-4c0a-bb9d-4a95b6dd4fe6 | OstermD/EAIK | CPP/src/IK/utils/kinematic_utils.cpp | #include <eigen3/Eigen/Dense>
#include <math.h>
#include <iostream>
#include "kinematic_utils.h"
namespace IKS
{
std::tuple<Eigen::MatrixXd, Eigen::MatrixXd, Eigen::Matrix3d> dh_to_H_P(const Eigen::VectorXd& dh_alpha, const Eigen::VectorXd& dh_a, const Eigen::VectorXd& dh_d)
{
Eigen::MatrixXd H (3, dh_... | ALGO | 0.998856 | 4.887002 |
d79bcc69-e7a2-4bc9-8a7f-d566a1c07338 | tmnguyen1403/AlgorithmC- | Problems/BitManipulation/reverse_bits.cpp | class Solution {
public:
uint32_t reverseBits(uint32_t n) {
uint32_t result = 0;
for(uint8_t i = 0; i < 32; ++i) {
result += (n & 1) << (31 - i);
n = n >> 1;
}
return result;
}
}; | ALGO | 0.999851 | 6.110561 |
fc2b8f4a-59c7-4b84-8ee3-1b49c19efdd2 | LordRadai/Morpheme4 | common/NMNumerics/src/NMSolverQR_imp.cpp | // Check if the tolerances have been defined
#ifndef NMSOLVER_ETOL
#error Machine precision tolerance undefined
#endif
//----------------------------------------------------------------------------------------------------------------------
namespace NMP
{
//----------------------------------------------------------... | ALGO | 0.99728 | 6.145461 |
ca9fbad4-6fab-4af8-90ea-b4cd1a42b08c | Zapeth/ext-boost | libs/atomic/src/find_address_sse41.cpp | /*!
* \file find_address_sse41.cpp
*
* This file contains SSE4.1 implementation of the \c find_address algorithm
*/
#include <boost/predef/architecture/x86.h>
#include <boost/atomic/detail/int_sizes.hpp>
#if BOOST_ARCH_X86 && defined(BOOST_ATOMIC_DETAIL_SIZEOF_POINTER) && (BOOST_ATOMIC_DETAIL_SIZEOF_POINTER == ... | ALGO | 0.986752 | 6.262462 |
9d698ac8-b043-402a-9bd6-ddd3e3fe13ec | siri3us/siri3us.github.io | code/linking/dynamic_cyclic/sum.cpp | #include "math1.h"
double Sum(double a, double b) {
return _SumImplementationFromMath1(a, b);
}
double _MultImplementationFromMath2(double a, double b) {
return a * b;
}
| TOOL | 0.996205 | 5.35821 |
7796e34d-5f8b-420a-843e-7cf49c738a1e | yuexunshi/flutter_chat | windows/runner/utils.cpp | #include "utils.h"
#include <flutter_windows.h>
#include <io.h>
#include <stdio.h>
#include <windows.h>
#include <iostream>
void CreateAndAttachConsole() {
if (::AllocConsole()) {
FILE *unused;
if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
_dup2(_fileno(stdout), 1);
}
if (freopen_s(&unuse... | TOOL | 0.998859 | 6.785645 |
3486a48c-840c-496e-86ab-ade23f355360 | nawafuji/PBSproject | WaterTest/src/sph.cpp |
//TODO: reset rho(i) to 0 or rho_0 in computedensity???
#include <iostream>
#include <Eigen/Dense>
#include <cmath>
#include <random>
#include "sph.h"
using namespace Eigen;//Eigen::Matrix2Xd, Eigen::MatrixXd,Eigen::MatrixXi,Eigen::VectorXd;
const int N_start=0;
const double d=0.05; //1.
const double h=0.100001;//2... | ALGO | 0.999874 | 3.117775 |
481c5699-8888-407f-a692-7cb35cf9d98c | SaxJ/programming-comps | codeforces/practice/add_odd_sub_even.cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin >> T;
for (int t = 0; t < T; t++) {
int a, b;
cin >> a >> b;
int diff = b - a;
if (diff == 0)
cout << 0 << endl;
else if (diff > 0) {
if (diff % 2 == 0)
cout... | ALGO | 0.999964 | 4.342394 |
e0dc2c38-cbd0-48e4-b6d6-79026eac1b34 | hbkkk/mygit | leetcode/Longest Increasing Subsequence/Longest Increasing Subsequence.cpp | /*
最长上升子序列,朴素的做法是用dp[i]表示以下标为i的数为尾的最长上升子序列的长度,然后 time O(n^2)可以做
更好的做法是O(n)扫一遍数组,用dp数组维护当前的最长上升子序列
然后对于扫到的每个数,用二分O(logn)来插入dp数组以维护这个最长上升子序列
于是总的 time O(nlogn)
详见代码,这样更好理解
*/
class Solution {
public:
int lengthOfLIS(vector<int>& nums) {
if(nums.size() == 0) return 0;
int *dp = ... | ALGO | 0.999992 | 5.591562 |
f64b79ac-19e1-4511-9d6d-86934897be84 | andrewboutros/csc2512_a2 | encode_clustering.cpp | #include <iostream>
#include <fstream>
#include <sstream>
#include <unordered_map>
#include <utility>
#include <vector>
#include <stdlib.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
// Hash function for pair data type
struct hash_pair {
template <class T1, class T2>
size_t operator... | ALGO | 0.958743 | 4.245658 |
0cb94b1f-46da-4cb8-adb7-e2b3dcf222ef | lorden95/codeando | 2_EstructurasDeControl/SolucionesTarea2/EstructurasRepetitivas/Ejercicio 3 bucle.cpp | /* Realice un programa que calcule y muestre en la salida estndar la suma de los cuadrados de los 10 primeros enteros mayores que cero */
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int suma = 0;
for(int i=1;i<=10;i++){
suma += pow(i,2);
}
cout<<suma<<endl;
return 0;
}
| ALGO | 0.99238 | 3.737105 |
1f96d807-1e5e-4e38-ac3b-840ffb0c93df | mrdealba/llvm | libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp | // <algorithm>
// Test std::partial_sort stability randomization
// UNSUPPORTED: c++03
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
#include <algorithm>
#include <array>
#include <cassert>
#include <functional>
#include <iterator>
#include <vector>
#include "test_macros.h"
struct My... | TEST | 0.987039 | 7.193001 |
77b539c4-1431-45f3-ac41-b2ddbd4ab782 | nubomedia-vtt/armodule | ar-markerdetector/src/server/implementation/objects/Process.cpp | /** @author Markus Ylikerälä */
#include "Process.h"
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "unistd.h"
#include "sys/wait.h"
#include <GL/gl.h>
#include <GL/glext.h>
#include "ArMarkerdetector.hpp"
#include "MarkerDete... | TOOL | 0.888604 | 3.460065 |
3e100f8a-f2f3-45c4-a43f-fe92c9a4113b | subramanian0/CSES-Judge-Solutions | Removing_Digits.cpp | #include <iostream>
#include <sstream>
#include <climits>
#include <map>
#include <algorithm>
#include <cstring>
using namespace std;
int main() {
int str;
cin>>str;
int dp[1000005];
for(int i=0;i<=1000005;i++)
dp[i] = INT_MAX;
dp[0] = 0;
for(int i=1;i<=str;i++)
{
if(i<=9) dp[i] = 1;
else
{
int digit;... | ALGO | 0.999454 | 4.026486 |
70a7dad1-ef62-426f-9112-d6193ecbd960 | alex-roh/Acmicpc_Problem_Solving | 브루트 포스를 활용한 풀이/1963 - 소수 경로/main.cpp | #include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <climits>
using namespace std;
vector<bool> isPrime(10000, true);
void findPrimes(){
isPrime[0] = false;
isPrime[1] = false;
for(int i = 2; i <= 10000; i++){
if(isPrime[i] == false) continue;
else{
for(int j = i * 2; j <=... | ALGO | 0.999947 | 4.452726 |
2d94e1e2-adc6-401a-aaba-f44578fbab4c | loboska1231/leetcode_ | АСД/lab6.cpp | #include <iostream>
using namespace std;
struct NODE
{
int key;
int value;
NODE* next;
NODE() : key(NULL), value(NULL), next(nullptr) {};
NODE(int _key, int _value) : key(_key), value(_value), next(nullptr) {};
void printNode()
{
cout << "(" << key << ", " << value << ") ";
}
};
class myHashTable
{
private:
... | ALGO | 0.997431 | 4.161764 |
45203214-4229-4a03-80dc-bd2d9ab0ba45 | koosaga/olympiad | ICPC/Japan/jagsummer15_e.cpp | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <functional>
#include <numeric>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <bitset... | ALGO | 0.999982 | 4.443526 |
ec132cee-569c-43ab-90c6-8c8eb09dfffa | Wild-Donkey/Code | ybt/ybt1250-1299/ybt1260 拦截导弹plus.cpp | #include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
//#include<minmax.h>
using namespace std;
int ans = 0, n = 1, a[1005], f[1005], d[1005], u = 0;
int main() {
while (cin >> a[n]) {
f[n] = 1;
n++;
}
n--;
for (int i = 2; i <= n; i++) {
for (int j = 1; j < i; j++) {
if (a[i] <= a[j]) {... | ALGO | 0.999957 | 3.724193 |
f0316d5d-ec49-491e-9e02-4d66ff5ae8b1 | fmckenna/OpenSeesBORIS | SRC/reliability/analysis/analysis/SystemAnalysis.cpp | // $Revision: 1.19 $
// $Date: 2010-06-10 18:53:31 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/SystemAnalysis.cpp,v $
//
// Written by Kevin Mackie (<EMAIL>)
//
#include <SystemAnalysis.h>
#include <ReliabilityDomain.h>
#include <ReliabilityAnalysis.h>
#include <LimitStateFunction.h>
#incl... | ALGO | 0.999047 | 5.736845 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.