I previously thought that you can “force” varibles in to a temporary struct by using {} to sort of “bind” them together. I used this a couple times before and they worked. But this time it didn’t work.
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
struct task{
long long a,b;
};
map<task,bool>tasks;
long long lst[10012],sum[10012],sub[10012];
int main(){
long long n,p,h,m;
cin>>n>>p>>h>>m;
for(int i=0;i<m;i++){
long long ta,tb;
cin>>ta>>tb;
task[{ta,tb}]=true;
}
for(auto &t:tasks){
task cur=t.first;
sub[cur.a+1]--;
sub[cur.b]++;
}
for(int i=1;i<=n;i++){
sum[i]=sub[i]+sum[i-1];
cout<<sum[i]<<endl;
}
}
So to restate the question:
How to use {} characters to assign multiple varibles into a temperary struct and then use them in the [] of a map
I tried add “task” before the { character but it didn’t work
I tried using a temporary varible to solve this problem. it worked but didn’t achieve my goal of learning this new element of syntax.
hello world2020 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.