Skip to content

Instantly share code, notes, and snippets.

@karngyan
Created May 24, 2018 00:56
Show Gist options
  • Save karngyan/ef1717a44f1010bd3228cbb875d83152 to your computer and use it in GitHub Desktop.
Save karngyan/ef1717a44f1010bd3228cbb875d83152 to your computer and use it in GitHub Desktop.
Vector of Vector of Pairs
/*
@author: karngyan
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::vector<ld> vld;
typedef std::vector< std::vector<ll> > vvll;
typedef std::pair<ll, ll> pll;
typedef std::vector< pll > vpll;
typedef unsigned long long int ull;
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define sz(a) (ll)((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define trvect(c,i) for(vector<ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define trset(c,i) for(set<ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define trmap(c,i) for(map<ll,ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define clr(c) (c).clear()
#define res(c,n) (c).reserve(n)
#define cres(c,n) (c).clear(),(c).reserve(n)
#define ff first
#define ss second
#define mk make_pair
#define sq(a) (a)*(a)
#define cube(a) (a)*(a)*(a)
#define cnti(x) (__builtin_popcount(x)) //number of set bits in x
#define cntl(x) (__builtin_popcountll(x))
int main()
{
#ifndef ONLINE_JUDGE
freopen("H:\\code\\input.txt", "r", stdin);
freopen("H:\\code\\output.txt", "w", stdout);
#endif
fast;
/////////////////////////////////////////////////////
int n,m;
cin>>n>>m;
vector< vector< pair<int,int> > > A(n, vector< pair<int,int> >(m));
// here we create a matrix of size n*m
// i.e. A has n vector of pairs where each vector of pairs have m pairs
//to take in
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>A[i][j].first;
cin>>A[i][j].second;
}
}
//to display what you took in
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cout<<A[i][j].first<<","<<A[i][j].second<<" ";
}
cout<<endl;
}
//////////////////////////////////////////////////////
#ifndef ONLINE_JUDGE
cout<<endl<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec"<<endl;
#endif
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment