Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //whats wrong here
- //i am using brute force.
- /*
- input:
- 14
- E 1 1
- E 2 1
- E 1 2
- E 2 2
- E 1 3
- E 3 1
- E 3 2
- D
- D
- D
- D
- D
- D
- D
- output://incorrect
- 1 3
- 1 2
- 1 1
- 2 2
- 2 1
- 3 2
- 3 1
- //should be
- 1 1
- 1 2
- 1 3
- 2 1
- 2 2
- 3 1
- 3 2
- */
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- #define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
- int main(){
- FASTER;
- int n;cin>>n;
- list<pair<int,int> > lst;
- for(int i=0;i<n;i++){
- char c;cin>>c;
- if(c=='E'){
- int sc,ro;cin>>sc>>ro;
- if(lst.size()<=1)
- lst.push_back({sc,ro});
- else{
- int flg=1;
- for(auto it=lst.begin();it!=lst.end();it++){
- if(sc==(it->first)){
- flg=0;
- lst.insert(it,{sc,ro});
- break;
- }
- }
- if(flg)lst.push_back({sc,ro});
- }
- }else{
- cout<<(lst.front()).first<<" "<<(lst.front()).second<<"\n";
- lst.pop_front();
- }
- }
- }
Add Comment
Please, Sign In to add comment