|
| 1 | +#include <bits/stdc++.h> |
| 2 | + |
| 3 | +using namespace std; |
| 4 | + |
| 5 | +int main() |
| 6 | +{ |
| 7 | + ///Problem A |
| 8 | + /* string s; |
| 9 | + cin>>s; |
| 10 | + set<int> st; |
| 11 | +
|
| 12 | + for(int i=0 ; i<s.size() ; i++) |
| 13 | + { |
| 14 | + st.insert(s[i]); |
| 15 | + } |
| 16 | +
|
| 17 | + if(st.size()%2==0) |
| 18 | + cout<<"CHAT WITH HER!"; |
| 19 | + else |
| 20 | + cout<<"IGNORE HIM!";*/ |
| 21 | + |
| 22 | + ///problem B |
| 23 | + |
| 24 | + /*string s; |
| 25 | + getline(cin,s); |
| 26 | + set<char>st; |
| 27 | + for(int i=0 ;i<s.size() ; i++ ) |
| 28 | + { |
| 29 | +
|
| 30 | + st.insert(s[i]); |
| 31 | + } |
| 32 | +
|
| 33 | +
|
| 34 | +
|
| 35 | +
|
| 36 | + if(st.size()>3) |
| 37 | + cout<<st.size()-4; |
| 38 | + else |
| 39 | + cout<<st.size()-2; |
| 40 | +
|
| 41 | + */ |
| 42 | + |
| 43 | + ///Problem c |
| 44 | + |
| 45 | + /* int t; |
| 46 | + cin>>t; |
| 47 | + string s1,s2; |
| 48 | + while(t--) |
| 49 | + { |
| 50 | +
|
| 51 | + cin>>s1>>s2; |
| 52 | + int f=0; |
| 53 | + set<char>st; |
| 54 | + for(int i=0 ; i<s1.size(); i++) |
| 55 | + { |
| 56 | +
|
| 57 | + st.insert(s1[i]); |
| 58 | + } |
| 59 | + for(int j=0 ; j<s2.size() ; j++) |
| 60 | + { |
| 61 | + if(st.find(s2[j])!=st.end()) |
| 62 | + { |
| 63 | + f=1; |
| 64 | + break; |
| 65 | + } |
| 66 | + } |
| 67 | +
|
| 68 | + if(f) |
| 69 | + { |
| 70 | + cout<<"YES\n"; |
| 71 | + } |
| 72 | + else |
| 73 | + cout<<"NO\n"; |
| 74 | +
|
| 75 | + }*/ |
| 76 | + |
| 77 | + ///problem D |
| 78 | + /* char c; |
| 79 | + cin>>c; |
| 80 | + string s="qwertyuiopasdfghjkl;zxcvbnm,./",s1,ans=""; |
| 81 | + cin>>s1; |
| 82 | +
|
| 83 | + ///Map |
| 84 | + if(c=='R') |
| 85 | + { |
| 86 | + map<char,char>mp; |
| 87 | + for(int i=1 ; i<s.size() ; i++) |
| 88 | + { |
| 89 | + mp[s[i]]=s[i-1]; |
| 90 | + } |
| 91 | + for(int i=0 ; i<s1.size() ; i++) |
| 92 | + { |
| 93 | + cout<<mp[s1[i]]; |
| 94 | + } |
| 95 | + } |
| 96 | + else |
| 97 | + { |
| 98 | + map<char,char>mp; |
| 99 | + for(int i=0 ; i<s.size()-1 ; i++) |
| 100 | + { |
| 101 | + mp[s[i]]=s[i+1]; |
| 102 | + } |
| 103 | + for(int i=0 ; i<s1.size() ; i++) |
| 104 | + { |
| 105 | + cout<<mp[s1[i]]; |
| 106 | + } |
| 107 | + } |
| 108 | +
|
| 109 | + ///string |
| 110 | +
|
| 111 | + /* if(c=='R') |
| 112 | + { |
| 113 | + for(int i=0 ; i<s1.size() ; i++) |
| 114 | + { |
| 115 | + // mp[s1[i]]->>s[i] |
| 116 | + int index=s.find(s1[i]); |
| 117 | + ans+=s[index-1]; |
| 118 | +
|
| 119 | + } |
| 120 | +
|
| 121 | + } |
| 122 | + else |
| 123 | + { |
| 124 | + for(int i=0 ; i<s1.size() ; i++) |
| 125 | + { |
| 126 | + int index=s.find(s1[i]); |
| 127 | + ans+=s[index+1]; |
| 128 | + } |
| 129 | +
|
| 130 | + } |
| 131 | + cout<<ans;*/ |
| 132 | + |
| 133 | + /* int n,m,x,y; |
| 134 | + cin>>n>>m; |
| 135 | + set<int>st; |
| 136 | + for(int i=0 ; i<n ; i++) |
| 137 | + { |
| 138 | + cin>>x; |
| 139 | + for(int j=0 ; j<x ; j++) |
| 140 | + { |
| 141 | + cin>>y; |
| 142 | + st.insert(y); |
| 143 | + } |
| 144 | + } |
| 145 | + if(st.size()==m) |
| 146 | + { |
| 147 | + cout<<"YES"; |
| 148 | + } |
| 149 | + else |
| 150 | + cout<<"NO";*/ |
| 151 | + |
| 152 | + /* int n; |
| 153 | + cin>>n; |
| 154 | +
|
| 155 | + string s[n+1]; |
| 156 | + for(int i=0 ; i<n ; i++) |
| 157 | + cin>>s[i]; |
| 158 | +
|
| 159 | + map<string,int>mp; |
| 160 | + for(int i=n-1 ; i>=0 ; i--) |
| 161 | + { |
| 162 | + if(mp[s[i]]!=1) |
| 163 | + { |
| 164 | + cout<<s[i]<<"\n"; |
| 165 | + mp[s[i]]=1; |
| 166 | + } |
| 167 | + }///O(nlogn) |
| 168 | + */ |
| 169 | + |
| 170 | + /* int q; |
| 171 | + cin>>q; |
| 172 | + while(q--) |
| 173 | + { |
| 174 | +
|
| 175 | +
|
| 176 | + int n,r,m; |
| 177 | + cin>>n>>r; |
| 178 | + set<int>st; |
| 179 | + for(int i=0 ; i<n ; i++) |
| 180 | + { |
| 181 | + cin>>m; |
| 182 | + st.insert(m); |
| 183 | + } |
| 184 | + auto itr=st.rbegin(); |
| 185 | + int cnt=0,dist; |
| 186 | + while(itr!=st.rend()) |
| 187 | + { |
| 188 | + dist=cnt*r; |
| 189 | + if(*itr-dist<=0) |
| 190 | + { |
| 191 | + break; |
| 192 | + } |
| 193 | + else{ |
| 194 | + cnt++; |
| 195 | + itr++; |
| 196 | + } |
| 197 | +
|
| 198 | + } |
| 199 | + cout<<cnt<<"\n"; |
| 200 | + }*/ |
| 201 | + ///O(NlogN) |
| 202 | + int q,x,m; |
| 203 | + cin>>q; |
| 204 | + int cnt=0; |
| 205 | + set<int> mono; |
| 206 | + set< pair<int,int> > poly; |
| 207 | + map<int,int>mp; |
| 208 | + while(q--) |
| 209 | + { |
| 210 | + cin>>x; |
| 211 | + if(x==1) |
| 212 | + { |
| 213 | + cnt++; |
| 214 | + cin>>m; |
| 215 | + mono.insert(cnt); |
| 216 | + poly.insert({m,cnt*-1}); |
| 217 | + mp[cnt]=m; |
| 218 | + } |
| 219 | + else if(x==2) |
| 220 | + { |
| 221 | + int customer=*(mono.begin()); |
| 222 | + cout<<customer<<" "; |
| 223 | + mono.erase(customer); |
| 224 | + poly.erase({mp[customer],customer*-1}); |
| 225 | + mp.erase(customer); |
| 226 | + } |
| 227 | + else{ |
| 228 | + pair<int,int> customer=*(poly.rbegin()); |
| 229 | + cout<<customer.second*-1<<" "; |
| 230 | + poly.erase(customer); |
| 231 | + mono.erase(customer.second*-1); |
| 232 | + mp.erase(customer.second*-1); |
| 233 | + } |
| 234 | + |
| 235 | + } |
| 236 | + ///O(nlogN) |
| 237 | + |
| 238 | + |
| 239 | + |
| 240 | + |
| 241 | + |
| 242 | + |
| 243 | + |
| 244 | + return 0; |
| 245 | +} |
0 commit comments