Created
March 4, 2019 17:49
-
-
Save garganshul108/ec30edd58023fdc0adbdb788cf53d69e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
#define ll long long | |
#define fr(v,s,n) for(int v=s;((s<n)?v<n:v>n);((s<n)?v++:v--)) | |
#define debug(p) cout<<#p<<' '<<p<<'\n'; | |
#define debuga(a,i) cout<<#a<<"["<<i<<"]"<<" "<<a[i]<<"\n"; | |
#define debugal(a) for(int v=0;v<(sizeof(a)/sizeof(a[0]));v++) cout<<#a<<"["<<v<<"]"<<" "<<a[v]<<"\n"; | |
#define debugm(a,i,j) cout<<#a<<"["<<i<<"]["<<j<<"]"<<" "<<a[i][j]<<"\n"; | |
using namespace std; | |
#define pb push_back | |
#define mp make_pair | |
#define vii vector<pair<int,int>> | |
#define vi vector<int> | |
#define si stack<int> | |
#define fread(ff) freopen(ff,"r",stdin); | |
#define fwrite(ff) freopen(ff,"w",stdout); | |
#define dbl double | |
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); | |
#define sec second | |
#define fst first | |
#include <chrono> | |
#define endtt auto stop = chrono::high_resolution_clock::now(); auto duration = chrono::duration_cast<chrono::microseconds>(stop - start); cout <<"\ntime: "<< (double)duration.count()/1000000.0 << endl; | |
#define starttt auto start = chrono::high_resolution_clock::now(); | |
struct photo{ | |
int id; | |
int m; | |
char orientation; | |
string tags[22]; | |
}; | |
int n; | |
int main() | |
{ | |
#if 1 | |
fread("e_shiny_selfies.txt"); | |
fwrite("e_output.txt"); | |
#endif | |
cin>>n; | |
photo gallery[n]; | |
fr(i,0,n) | |
{ | |
gallery[i].id = i; | |
cin>> gallery[i].orientation; | |
cin>> gallery[i].m; | |
fr(j,0,gallery[i].m) | |
{ | |
cin>>gallery[i].tags[j]; | |
} | |
} | |
cout<<"ofls taken\n"; | |
stack<int> stk; | |
stack<pair<int,int>> res; | |
cout<<"stavk init\n"; | |
fr(i,0,n) | |
{ | |
if(gallery[i].orientation == 'H') | |
{ | |
cout<<"[ushede H\n"; | |
res.push(mp(gallery[i].id,-1)); | |
} | |
else | |
{ | |
if(stk.empty()) | |
{ | |
stk.push(gallery[i].id); | |
} | |
else | |
{ | |
int temp = stk.top(); | |
stk.pop(); | |
cout<<"[ushede V\n"; | |
res.push(mp(gallery[i].id,temp)); | |
} | |
} | |
} | |
cout<<"psuhing done"; | |
cout<<res.size()<<"\n"; | |
while(!res.empty()) | |
{ | |
pair<int,int> temp = res.top(); | |
res.pop(); | |
if(temp.fst > -1) cout<<temp.fst; | |
if(temp.sec > -1) cout<<" "<<temp.sec; | |
cout<<"\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment