Skip to content

Instantly share code, notes, and snippets.

@anurudhp
Created August 8, 2021 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anurudhp/21268c833a74fd2bbc3ee0a9eb6858b9 to your computer and use it in GitHub Desktop.
Save anurudhp/21268c833a74fd2bbc3ee0a9eb6858b9 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using ull = unsigned long long;
#define trace(v) cerr << ">> " << #v << " = " << v << "\n"
int N;
void test_vector() {
cerr << "TESTING VECTOR\n";
VI init = {0, 0};
vector<VI> v(N, init);
int *p1 = &(v[0][0]);
int *p2 = &(v[1][0]);
int *p3 = &(v[2][0]);
trace((p2 - p1));
trace((p3 - p2));
}
void test_pair() {
cerr << "TESTING PAIR\n";
PII init = {0, 0};
vector<PII> v(N, init);
int *p1 = &(v[0].first);
int *p2 = &(v[1].first);
int *p3 = &(v[2].first);
trace((p2 - p1));
trace((p3 - p2));
}
int main() {
cin >> N;
test_vector();
test_pair();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment