답안 #165194

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
165194 2019-11-25T18:02:23 Z theStaticMind Deda (COCI17_deda) C++14
20 / 140
414 ms 37036 KB
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n,q,ind=0;
      cin>>n>>q;
      map<int,map<int,ii>> Q;
      vector<int>ans;
      for(int i=0;i<q;i++){
            char c;
            int x,y;
            cin>>c>>x>>y;
            if(c=='M')Q[x][i]={y,INF};
            else Q[x][i]={y,ind++};
      }
      set<int>data;
      ans.resize(ind,-1);
      for(map<int,map<int,ii>>::iterator itr=Q.begin();itr!=Q.end();itr++){
            for(map<int,ii>::iterator it=itr->second.begin();it!=itr->second.end();it++){
                  if(it->second.second==INF){
                        data.insert(it->second.first);
                  }
                  else{
                        set<int>::iterator a=data.lower_bound(it->second.first);
                        if(a!=data.end())ans[it->second.second]=*a;
                  }
            }
      }
      for(int i=0;i<ind;i++)cout<<ans[i]<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 380 KB Output isn't correct
3 Incorrect 6 ms 1016 KB Output isn't correct
4 Incorrect 378 ms 34052 KB Output isn't correct
5 Incorrect 414 ms 36812 KB Output isn't correct
6 Incorrect 404 ms 37036 KB Output isn't correct
7 Incorrect 389 ms 36600 KB Output isn't correct