SS
Someone good with c++ here?
Anonymous
SS
Okay
Anonymous
Anonymous
Here my question
We wont do your homework for you. Tell us what you have done so far and the problem you are facing instead.
Anonymous
Anonymous
I as much i study , as much i loose
Alfredo
Anonymous
Anonymous
Sachin
ok
Артём
What is operator T& in std::reference_wrapper<T> ??
I can't figure it out, how to apply this operator (I don't want to use get()).
source: https://en.cppreference.com/w/cpp/utility/functional/reference_wrapper/get
Anonymous
Артём
Thank you, I understood it means the other way to return the stored reference is to static_cast<T&>(my_refwraper) .
Sachin
Anonymous
That is correct except for that there are no rows and columns actually in memory. Also s[i] is not a 2d array. It is just a plain array of 11 chars. These arrays may be allocated at random places in memory.
Anonymous
is am right?
s is a pointer to an array of char* pointers. Each individual char* pointer is a pointer to an array of 11 chars.
Anonymous
It is like this. It can be used like a 2D array but there are multiple indirections using pointers. Couldn't get hold of a piece of paper. So had to draw it on a tissue.
Sachin
thx you so much
Sachin
i got it now
Anonymous
English xd
Hanz
#ASK
If i create an int variable, does it allocate bytes from the size of int? Or it will reallocate some memory only when i change the content so that more int value requires more memory?
ex:
int a = 0;
int sa = sizeof a;
a++;
printf("%d", sizeof a == sa);
klimi
You are allocating on stack so that means it will just move the stack pointer and there you have your memory.
In this case you will allocate 2x ints
Hanz
ooh alright! That make sense
Артём
Is second way less efficient?
1)
void fill(vector<int>& v) {
// fill v with large data
}
2)
vector<int> fill(vector<int>& v) {
// fill c with large data
return std::move(v);
}
.........
vector<int> v;
1)
fill(v);
2)
v = fill(v);
@𝑺𝒐𝒃𝒌𝒂
Hi guys! I used the code below to have an idea of the largest and smallest values belonging to the integral data types. I'm working in windows 10, 64bt
#include <iostream>
#include <climits>
using namespace std;
int main()
{
cout<<"INTEGER: "<<endl;
cout<<"Maximum: "<<INT_MAX<<endl;
cout<<"Minimum: "<<INT_MIN<<endl;
cout<<"LONG: "<<endl;
cout<<"Maximum: "<<DBL_MAX<<endl;
cout<<"Minimum: "<<DBL_MIN<<endl;
cout<<"LONG LONG: "<<endl;
cout<<"Maximum: "<<LLONG_MAX<<endl;
cout<<"Minimum: "<<LLONG_MIN<<endl;
return 0;
}
Output:
INTEGER :
Maximum: 2147483647
Minimum: - 2147483648
LONG:
Maximum: 2147483647
Minimum: -2147483648
LONG LONG:
Maximum: 9223372036854775807
Minimum: - 9223372036854775808
@𝑺𝒐𝒃𝒌𝒂
Hanz
Hanz
Hanz
int -> long -> long long
Golden Age Of
Anonymous
so there is no 4 bytes number type for modern machine because long == int?
long and int are both 4 bytes long on most x86 machines but it is not guaranteed to be so on all architectures.
Whether you use int and long depends on how portable you want your code to be. If you need 4 byte integers and you use int and then try porting your code to a machine where int is just 2 bytes long, you will run into issues. In this case you should have used long.
Hanz
Thanks for the explanation guys 🙏 Because i use int for all my projects 😂 i will alter them
@𝑺𝒐𝒃𝒌𝒂
RITESH
wap to demonstrate use of multi lavel inheritance.
RITESH
plese help me
@𝑺𝒐𝒃𝒌𝒂
Anonymous
@𝑺𝒐𝒃𝒌𝒂
Anonymous
Anonymous
Anonymous
Anonymous
Hello!
SS
You are given a roadmap of a country consisting of N cities and M roads. Each city has a traffic light. The traffic light has only 2 colors, Green and Red. All the traffic lights will switch their color from Green to Red and vice versa after every T seconds. You can cross a city only when the traffic light in the city is Green. Initially, all the traffic lights are Green. At a city, if the traffic light is Red, you have to wait for it to switch its color to Green. The time taken to travel through any road is C seconds. For each node x, find the number of routes that will take the minimum amount of time (in seconds) required to move from city 1 to city N passing through that city x. It is guaranteed that the given roadmap will be connected. Graph won’t contain multiple edges and self-loops.
Input Format
The first line contains 4 space-separated integers, N (1 <= N <= 103), M (N - 1 <= M <= (N(N-1)/2), T (1 <=T <=103) and C (1 <= C <=103). Next M lines contain two integers each, U and V denoting that there is a bidirectional road between U and V.
Output Format
Print N integers, where ith denotes the number of routes which will take the minimum amount of time (in seconds) required to move from city 1 to city N passing through that city i.
Sample Testcase #0
Testcase Input
5 5 3 5
1 2
1 3
2 4
1 4
2 5
Testcase Output
1 1 0 1 1
Explanation
Fastest path will be 1 - > 2 - > 5. You can reach city 2 in 5 seconds. After 3 seconds the traffic light in
city 2 will turn Red. So in city 2, you have to wait for 1 second for the traffic light to turn Green. So total
time will be 5 seconds (from city 1 to city 2) + 1 second (waiting time at city 2) + 5 seconds (from city
2 to city 5) = 11 seconds.
There is no path from city 1 to city 5 through city 3
SS
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector<int> g[1001];
vector<pair<ll,vector<ll>>> pt;
void dfs(ll st,ll e,ll vis[],vector<ll> rs,ll w){
rs.push_back(st);
if(st == e){
pt.push_back({w*(rs.size()-1),rs});
return;
}
for(auto u : g[st]){
if(vis[u] == 0){
vis[st] = 1;
dfs(u,e,vis,rs,w);
vis[st] = 0;
}
}
}
int main()
{
ll n,m,t,c,u,v;
cin>>n>>m>>t>>c;
while(m--){
cin>>u>>v;
g[u].push_back(v);
g[v].push_back(u);
}
vector<ll> rs;
ll w = c;
ll vis[n+1] = {0};
dfs(1,n,vis,rs,w);
sort(pt.begin(),pt.end());
vector<ll> rt[n+1];
for(int i=0;i<pt.size();i++){
ll nes = pt[i].second.size();
for(auto u : pt[i].second){
rt[u].push_back(nes);
}
}
ll trt[n+1] = {0};
trt[1] = 1;
trt[n] = 1;
for(int i=2;i<=n-1;i++){
if(rt[i].size() > 0){
ll tm = rt[i][0];
ll up = upper_bound(rt[i].begin(),rt[i].end(),tm) - rt[i].begin();
trt[i] = up;
}
}
for(int i=1;i<=n;i++)
cout<<trt[i]<<" ";
return 0;
}
SS
I tried this code but 7 test cases work
Can someone pls resolve the issue?
tao
I recently used cppflow on VS 2019 on Windows 10.
My original data is data in 4 columns per row. I want to use neural network to classify precipitation particles. I have trained and saved my model (.pb) on python. Because it is text data in .txt, and the example described in the cppflow document uses pictures as input, I would like to ask what is the function of cppflow input in .txt text?
tao
Thank you
Φ ☭
/rules
Shourya
Any wifi driver developers here? ..Need some help in debugging intel 7260 dual band driver..
Shourya
I know what debugging means ..Not asking to debug for me ..By help I meant if there are JTAG kind of debuggers available for intel drivers
Anonymous
hi
Jasur Fozilov 🐳
/get cbook
Jasur Fozilov 🐳
/get cppbookguide
Anonymous
1 || ++n > 5
Can someone explain to me why the ++n is not evaluated? I get that logical OR doesn't need to evaluate the second expression if the first expression is true, but prefix comes before logical OR in operator precedence, so why doesn't n get incremented?
If this is how these two operators work, what's the point of placing prefix above logical OR in the same precedence table?
Alieya MIN
https://wandbox.org/permlink/fVrrnwoJjOuKd8tz hai guys i want to ask how to put the total quantity that have ordered per day and quantity that bought buy customer? any tips?
Anonymous
Anonymous
tao
tao
here is my data sample
tao
/40.900352,0.406250,9.900000,0.380615,6.000000
Alieya MIN
Alieya MIN
Anonymous
/40.900352,0.406250,9.900000,0.380615,6.000000
You can just create a tensor directly from this input. You dont even need a file. Look at their examples. They have lots of them covering different scenarios. Not all the inputs are image files.
Alieya MIN
Alieya MIN
its quite confusing there