int main() {

    int n,W,H;
    while(~scanf("%d%d%d",&n,&W,&H)) {
        init();
        maxbright = 0;
        for(int i = 0;i < n;i ++) {
            scanf("%d%d%d",&all[i].x,&all[i].y,&all[i].shine);
            mapy[all[i].y] = 0;
        }
        sort(all,all+n,cmp);
        int countf = 0;
        for(map<int ,int >::iterator it = mapy.begin();it != mapy.end();it ++) {
            countf ++;
            it -> second = countf;
        }
        int i,j ;
        i = 0;j= 0;
        while(i < n) {

            while(all[i].x - all[j].x >=  W) {
                add(1,countf,1,-all[j].shine,mapy.upper_bound(all[j].y - H) -> second,mapy[all[j].y]);
                j ++;
            }
            add(1,countf,1,all[i].shine,mapy.upper_bound(all[i].y - H) -> second,mapy[all[i].y]);
            maxbright = max(maxbright,getMax());
            i ++;
        }
        printf("%d\n",maxbright);
    }


}
Example #2
0
long long  solve(long long  x){
    long long  res = 0;
    int r = 0, l = 0;
    queue<STAR> q;
    for(int i = 0;i < n;i++){
	if(stars[i].second != x)continue;
	while(stars[r].first.first < stars[i].first.first - x)r++;
	while(l < n && stars[i].first.first >= stars[l].first.first - x) l++;
	i = l;
	for(;r < l;r++){
	    if(stars[r].second < x)continue;
	    q.push(stars[r]);
	    while(!q.empty() && q.front().first.first  < stars[r].first.first - x){
		STAR tmp = q.front();q.pop();
		map<long long, long long>::iterator it = zahyou.upper_bound(tmp.first.second + x);
		add_segtree(zahyou[tmp.first.second], (*--it).second, root, -1);
	    }
	    map<long long, long long>::iterator it = zahyou.upper_bound(stars[r].first.second + x);
	    add_segtree(zahyou[stars[r].first.second], (*--it).second, root, 1);
	    res = max(res, root -> all + root -> maximum);
	}
	r = i;
    }
    while(!q.empty()){
	STAR tmp = q.front();q.pop();
	map<long long, long long>::iterator it = zahyou.upper_bound(tmp.first.second + x);
	add_segtree(zahyou[tmp.first.second], (*--it).second, root, -1);
    }  
    return res;
}
Example #3
0
 void scanAscending(RecordListResponse& _return, const map<string, string>& mymap,
           const string& startKey, const bool startKeyIncluded,
           const string& endKey, const bool endKeyIncluded,
           const int32_t maxRecords, const int32_t maxBytes) {
     map<string, string>::const_iterator itr = startKeyIncluded ? 
         mymap.lower_bound(startKey):
         mymap.upper_bound(startKey);
     int numBytes = 0;
     while (itr != mymap.end()) {
         if (!endKey.empty()) {
             if (endKeyIncluded && endKey < itr->first) {
               break;
             }
             if (!endKeyIncluded && endKey <= itr->first) {
               break;
             }
         }
         Record record;
         record.key = itr->first;
         record.value = itr->second;
         numBytes += record.key.size() + record.value.size();
         _return.records.push_back(record);
         if (_return.records.size() >= (uint32_t)maxRecords || numBytes >= maxBytes) {
             _return.responseCode = ResponseCode::Success;
             return;
         }
         itr++;
     }
     _return.responseCode = ResponseCode::ScanEnded;
 }
Example #4
0
int main()
{
	int T;
	cin >> T;
	while(T--)
	{
		cin >> N;
		init();
		M.clear();
		for(int t = 0; t < N; t++)
		{
			int x;
			scanf("%d", &x);
			//printf("input %d\n", x);
			//for(map<int, int>::iterator it = M.begin(); it != M.end(); it++)
				//printf("%d ", it->first);
			//cout << endl;
			map<int, int>::iterator it = M.upper_bound(x + 1);
			if(it == M.begin())
			{
				int i = insert(x, -1, head);
				M[x] = i;
			}
			else
			{
				it--;
				int i = insert(x, it->second, list[it->second][2]);
				if(it->first == x + 1) M.erase(it);
				M[x] = i;
			}
			//print();
		}
		print();
	}
}
 void addNum(int val)
 {
   if (intervals_.empty()) {
     intervals_[val] = val;
     return;
   }
   auto ub = intervals_.upper_bound(val);
   if (ub == intervals_.begin()) {
     if (ub->first - 1 == val) {
       intervals_[val] = ub->second;
       intervals_.erase(ub);
     } else
       intervals_[val] = val;
   } else {
     auto p = prev(ub);
     if (ub == intervals_.end() || ub->first - 1 > val) {
       if (p->second + 1 < val)
         intervals_[val] = val;
       else if (p->second + 1 == val)
         p->second = val;
     } else {
       if (p->second + 1 < val)
         intervals_[val] = ub->second;
       else if (p->second + 1 == val)
         p->second = ub->second;
       intervals_.erase(ub);
     }
   }
 }
bool work(int t, int m) {
	int x = max_x[0];
	rep(i, m) {
		auto next = yc.upper_bound(max_y[xc.lower_bound(x - t)->snd] + t);
		if(next == yc.end()) return true;
		x = max_x[next->snd];
	}
Example #7
0
string
find_symbol (int addr)
{
  map<uint16_t,string>::iterator mi;
  mi = exports.upper_bound(addr);

  if (exports.empty() || mi == exports.begin())
    {
      std::stringstream ss;
      ss << '$' << std::hex << addr;
      return ss.str();
    }
  else
    {
      mi--;
      if (mi->first == addr)
	return mi->second;
      else
        {
	  std::stringstream ss;
	  ss << mi->second << "+" << addr - mi->first;
	  return ss.str();
	}
    }
}
		/* This function returns the minimum/maximum value at x. */
		double get_value(double x)
		{	
			map<double, Line>::iterator it = query_set.upper_bound(x);
			it--;

			return x*it->s.m + it->s.c;
		}
Example #9
0
string f (int x) {
  auto up = mapa.upper_bound(x);
  up --;
  int key = up -> first;

  if (key == x) return mapa[x];
  return mapa[key] + f(x - key);
}
Example #10
0
bool canInsert(int p, int q)
{
	auto upper = nerds.upper_bound(p);
	if (upper == nerds.end()) return true;


	return upper->second <= q;
}
Example #11
0
int main() {
	int q;
	cin >> q;
	
	char c;
	int x, l, h, t, b;
	while (q--) {				
		// cin >> c >> x;
		scanf(" %c %d", &c, &x); // faster than cin
		if (c == '+') {
			hmap[x]++;
		} else if (c == '-'){
			hmap[x]--;
			if (hmap[x] == 0)
				hmap.erase(x);			
		} else { // find max value
			l = 0;
			h = ((ll)1 << 31) - 1;
			t = h ^ x; // this is the target we want to find in A

			for (int i = 30; i >= 0; i--) {
				b = t & (1 << i);
				if (b) { // i th target bit is 1
					h = h | (1 << i);
					l = l | (1 << i);
					if (hmap.lower_bound(l) == hmap.upper_bound(h)) { // no value between l and h
						// reverse
						h = h & (~(1 << i));
						l = l & (~(1 << i));
					}
				} else {
					h = h & (~(1 << i));
					l = l & (~(1 << i));
					if (hmap.lower_bound(l) == hmap.upper_bound(h)) { // no value between l and h
						h = h | (1 << i);
						l = l | (1 << i);
					}
				}
			}
			cout << max(x, l^x) << endl;
		}		
	}	
	return 0;
}
Example #12
0
int main(){
    scanf("%d %d",&n,&m);
    low.insert(0);
    low.insert(n);
    high.insert(n);
    high.insert(2*n);
    for(int i=0; i<m; i++){
        char b[5];
        int x, y;
        scanf("%s %d %d",b,&x,&y);
        if(*b == 'B'){
            if(x > y) swap(x, y);
            if(y <= n){
                low.insert(x);
            }
            else{
                high.insert(x);
            }
        }
        if(*b == 'Q'){
            if((x-1) / n == (y-1) / n){
                if(x <= n && x > y){
                    auto u = mp1.lower_bound(x);
                    auto v = low.lower_bound(x);
                    if(u == mp1.end() || (v != low.end() && *v < u->first)) puts("NE");
                    else move(u->second, y);
                }
                else if(x <= n && x <= y){
                    auto t = low.lower_bound(x);
                    puts(y <= *t ? "DA" : "NE");
                }
                else if(x > n && x >= y){
                    auto t = --high.lower_bound(x);
                    puts(*t+1 <= y ? "DA" : "NE");
                }
                else{
                    auto u = mp2.upper_bound(x);
                    auto v = high.lower_bound(x);
                    if(u == mp2.begin()) puts("NE");
                    else{
                        u--;
                        if(v != high.begin() && *--v >= u->first){
                            puts("NE");
                        }
                        else move(u->second, y);
                    }
                }
            }
            else move(x, y);
        }
        if(*b == 'A'){
            if(x > y) swap(x, y);
            ins(x, y);
        }
    }
}
Example #13
0
bool query(int sx, int ex, int sy, int ey){
    auto itl = mp1.lower_bound(sx);
    auto itr = mp1.upper_bound(ex);
    if(itl == mp1.end() || itl->first > ex) return 0;
    if(itl->second > ey) return 0;
    itr--;
    if(itr->second < sy) return 0;
    auto ity = mp2.lower_bound(sy);
    if(ity == mp2.end() || ity->first > ey) return 0;
    return 1;
}
Example #14
0
struct Node* get(size_t key){
	struct Node* getNode;
	map<size_t, struct Node*>::iterator it = consistentHash.upper_bound(key);
	if (it == consistentHash.end()){
		getNode = consistentHash.begin()->second;
	}
	else{
		getNode = it->second;
	}

	return getNode;
}
Example #15
0
bool gao()
{
	int a,b;
	map<int,int>::iterator it;
	scanf("%d%d",&a,&b);
	it=mp0.lower_bound(a);
	if(b<it->second) return 0;
	it=mp1.upper_bound(a);
	--it;
	if(b>it->second) return 0;
	return 1;
}
Example #16
0
LL solve() {
	int n;
	getint2(m, n);
	ans = 0;
	for(int i = 0; i < n; i++) {
		getint2(k[i], l[i]);
		k[i] = k[i] - l[i] + 1;
		for (int j = 0; j < l[i] - 1; j++) {
			int x;
			getint(x);
		}
		for (int j = 0; j < k[i]; j++) {
			getint(a[i][j]);
		}
		for (int j = 0; j < l[i] - 1; j++) {
			int x;
			getint(x);
		}
		for (int j = 0; j < k[i] - 1; j++) {
			getint(c[i][j]);
		}
	}
	for (int i = 0; i < (1 << n); i++) {
		if (__builtin_popcount(i) != 8)
			continue;
		int s = i;
		vector<int> l, r;
		for (int j = 0; j < n; j++) {
			if (s & 1) {
				if (l.size() != 4)
					l.pb(j);
				else
					r.pb(j);
			}
			s >>= 1;
		}
		solve(l, lans);
		solve(r, rans);
		if (rans.empty())
			continue;
		for (map<int, LL>::iterator it = lans.begin(); it != lans.end(); it++) {
			if (m - it->c0 < 0)
				break;
			map<int, LL>::iterator rit = rans.upper_bound(m - it->c0);
			if (rit == rans.begin())
				break;
			rit--;
			chkmax(ans, it->c1 + rit->c1);
		}
	}
	return ans;
}
Example #17
0
  bool get_next(const K &key, pair<K, V> *next) {
    VPtr next_val;
    Mutex::Locker l(lock);
    typename map<K, pair<WeakVPtr, V*> >::iterator i =
      contents.upper_bound(key);
    while (i != contents.end() &&
	   !(next_val = i->second.first.lock()))
      ++i;
    if (i == contents.end())
      return false;
    if (next)
      *next = make_pair(i->first, *next_val);
    return true;
  }
Example #18
0
bool self_modifying(uword location) {
	log3("self_modifying| location:%04hx", location);

	map<uword, uword>::iterator it = startEnd.upper_bound(location);

	if(it == startEnd.end() || it->first <= location )
		return false;

	codeLocation.erase(it->first);
	
	log2("self_modifying| deleting block (start: %04hx, end: %04hx)", it->second, it->first);

	return it->second == IP;
}
Example #19
0
void split(int i,Node* &L,Node* &M,Node* &R){
  it=l_node.upper_bound(i);
  --it;
  splay(M=it->second);
  L=newNode(i-M->l,M->l);
  R=newNode(M->l+M->v-1-i,i+1);
  M->ch[0]->fa=M->ch[1]->fa=null;
  L=merge(M->ch[0],L);
  R=merge(R,M->ch[1]);
  M->ch[0]=M->ch[1]=null;
  M->v=1;
  M->l=i;
  l_node[i]=M;
  M->maintain();
}
Example #20
0
int main()
{
	//ios::sync_with_stdio(false);
	//cin.tie(0);
//	printf("%d\n", inf);
	for (int i = 0; i < MAXN; i++)
		for (int j = 0; j < 2; j++)
			for (int k = 0; k <= MAXM; k++)
				dp[i][j][k] = inf;

	int n, u, v, w;
	scanf("%d", &n);
	//cin >> n;

	for (int i = 1; i <= n; i++)
		scanf("%d", &Value[i]);
	//cin >> Value[i];

	for (int i = 1; i < n; i++)
	{
		scanf("%d %d %d", &u, &v, &w);
		//cin >> u >> v >> w;
		Children[u].push_back(v);
		Children[v].push_back(u);
		Edge[u][v] = w;
		Edge[v][u] = w;
	}
	dfs(1, 0);
	ans[0] = 0;
	for (int i = 1; i <= MAXM; i++)
	{
		int d = min(dp[1][0][i], dp[1][1][i]);
		ans[d] = i;
	}
	int q, d;
	scanf("%d", &q);
	//cin >> q;
	for (int i = 1; i <= q; i++)
	{
		scanf("%d", &d);
		//cin >> d;
		auto it = ans.upper_bound(d);
		printf("%d\n", (--it)->second);
	}
	return 0;
}
Example #21
0
    optional<Data> select(Index lower_bound, Index upper_bound, std::function<bool(const Data&)> pred) {
        auto l = index.lower_bound(lower_bound);
        auto u = index.upper_bound(upper_bound);

        auto key = *find_if(l, u, [pred, this](pair<Index, size_t> pair) {
            if (rows.size() > pair.second) {
                return pred(rows.at(pair.second));
            }
            return false;
        });

        // not found
        if (key.first >= upper_bound) {
            return optional<Data>();
        }

        return rows.at(key.second);
    }
Example #22
0
int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++) {
		hh.insert(make_pair(an,i));
		int b;
		scanf("%d",&b);
		an+=b;
	}
	hh.insert(make_pair(an,n+1));
	for(int i=0;i<q;i++) {
		int b;
		scanf("%d",&b);
		if((hh.lower_bound(b)->first)==b){
		    printf("%d\n",hh.lower_bound(b)->second);
            continue;
		}
		printf("%d\n",(hh.upper_bound(b))->second-1);
	}
}
Example #23
0
    /*static*/ void* MongoMMF::switchToPrivateView(void *readonly_ptr) { 
        void *p = readonly_ptr;
        assert( durable );
        assert( debug );
        mutex::scoped_lock lk(our_views_mutex);
        std::map< void*, MongoMMF* >::iterator i = 
            our_read_views.upper_bound(((char *)p)+1);
        i--;

        bool ok = i != our_read_views.end();
        if( ok ) {
            MongoMMF *mmf = i->second;
            assert( mmf );

            size_t ofs = ((char *)p) - ((char*)mmf->view_readonly);

            if( ofs < mmf->length() ) { 
                return ((char *)mmf->view_private) + ofs;
            }
        }

        if( 1 ) { 
            static int once;
            /* temp : not using MongoMMF yet for datafiles, just .ns.  more to do... */
            if( once++ == 0 )
                log() << "TEMP TODO _DURABLE : use mongommf for datafiles" << endl;
            return p;
        }

        for( std::map<void*,MongoMMF*>::iterator i = our_read_views.begin(); i != our_read_views.end(); i++ ) { 
            char *wl = (char *) i->second->view_private;
            char *wh = wl + i->second->length();
            if( p >= wl && p < wh ) { 
                log() << "dur: perf warning p=" << p << " is already in the writable view of " << i->second->filename() << endl;
                return p;
            }
        }
        log() << "switchToPrivateView error " << p << endl;
        assert( false ); // did you call writing() with a pointer that isn't into a datafile?
        return 0;
    }
Example #24
0
bool is_it_possible() {
	int i,j,cnt;
	while(!q.empty()) q.pop();
	for(i=1;i<=n;i++) {
		if(v.find(i)!=v.end()) for(j=0;j<(int)(v[i].size());j++) q.push(v[i][j]);
		if(!q.empty() && q.top()<i) return false;
		if(q.empty()) {
			it=v.upper_bound(i);
			if(it==v.end()) break;
			i=((*it).first)-1;
			continue;
		}
		cnt=0;
		while(!q.empty() && cnt<e) {
			++cnt;
			q.pop();
		}
	}
	if(q.empty()) return true;
	else return false;
}
Example #25
0
  bool get_next(const K &key, pair<K, VPtr> *next) {
    pair<K, VPtr> r;
    {
      Mutex::Locker l(lock);
      VPtr next_val;
      typename map<K, pair<WeakVPtr, V*>, C>::iterator i = weak_refs.upper_bound(key);

      while (i != weak_refs.end() &&
	     !(next_val = i->second.first.lock()))
	++i;

      if (i == weak_refs.end())
	return false;

      if (next)
	r = make_pair(i->first, next_val);
    }
    if (next)
      *next = r;
    return true;
  }
Example #26
0
File: h.cpp Project: KyleJu/ACM
int main(){
	int ts; cin>>ts;
	while(ts--) {
		m.clear();
		int ss; cin >>ss;
		string t; getline(cin,t);
		for (int i =0; i < ss; i++) {
			string s;
			getline(cin, s);
			istringstream iss{s};
    		vector<string> wrds{istream_iterator<string>{iss},istream_iterator<string>{}};
    		cerr << wrds[0] << " " << wrds[1] << " " ; 
    		m[mp(wrds[1])] = wrds[0];
    		if (wrds.size() >2){
    			cerr << wrds[2];
    			if (wrds[2] != " ") m[mp(wrds[2])] = wrds[0];
    		}
    		cerr << "\n";

		}
		int q; cin >>q;
		getline(cin,t);
		//index problems
		for (int j = 0; j < q; j++) {
			string s; getline(cin, s);
			for (int i= 0; i < s.size(); i++) {

				if (( (int) (s[i] - '0') >= 0 && (int)(s[i] - '0') < 10) || s[i] == '.') {
					int left = i;
					while(( (int)(s[i] - '0') >= 0 && (int)(s[i] - '0') < 10) || s[i] == '.') {
						i++;
					}
					i--;
					ll ke = mp(s.substr(left, i - left + 1));
					cerr << s.substr(left , i - left + 1) << " string testing **" << endl;
					
					//if (m.find(ke) != m.end()){
					if (m.find(ke) != m.end()) {
						cout << m[ke];
					} else {
						auto it = m.upper_bound(ke);
                        if (it == m.end() || it == m.begin()) {
							cout << s.substr(left, i - left + 1);
                            continue;
                        }
						string tmp = it->second;
						it--;
						string tmp2 = it->second;
						if (tmp == tmp2)
							cout << tmp;
						else
							cout << s.substr(left, i - left + 1);
					}

				} else {
					cout << s[i];
				}
			}
			cout << "\n";
		}




	}
}
Example #27
0
int main() {
    int T;
    cin>>T;
    for(int t=1;t<=T;t++) {
        cout << "Case #" << t << ":" << endl;
        int n, q;
        ll w, h;
        scanf("%d %d %lld %lld", &n, &q, &w, &h);
        m.clear();
        vector<pii> ans(n);
        for(int i=0;i<n;i++) {
            ll x, y;
            scanf("%lld %lld", &x, &y);
            ans[i] = pii(x, y);
            add(x-y, x+y, i);
        }
        while(q--) {
            ll E, a, b, c, d, e, f, x, y;
            scanf("%lld %lld %lld %lld %lld %lld %lld %lld %lld", &x, &y, &E, &a, &b, &c, &d, &e, &f);
            ll nx = x-y, ny=x+y;
            ll minx = nx - E, maxx = nx + E;
            ll miny = ny - E, maxy = ny + E;
            map<int, set<pii> >::iterator it = m.upper_bound(maxx);
            if(it == m.begin()) continue;
            it--;
            vector<pair<pii, int> > vadd;
            while(1) {
                if(it->first < minx) break;
                set<pii>::iterator its = it->second.upper_bound(pii(maxy, n));
                if(its != it->second.begin())
                {
                    its--;
                    while(1) {
                        if(its->first < miny) break;
                        ll oldx = it->first, oldy = its->first;
                        int pos = its->second;
                        ll A=(oldx+oldy)/2, B=(oldy-oldx)/2;
                        nx = ((A * a) + (B * b) + ((pos+1)*c)) % w;
                        ny = ((A * d) + (B * e) + ((pos+1)*f)) % h;
                        ans[pos] = pii(nx, ny);
                        vadd.push_back(make_pair(pii(nx-ny, nx+ny), pos));
                        if(its == it->second.begin()) {
                            it->second.erase(its);
                            break;
                        }
                        else {
                            it->second.erase(its--);
                        }
                    }
                }
                if(it->second.size() == 0) {
                    if(it == m.begin()) {
                        m.erase(it);
                        break;
                    }
                    else {
                        m.erase(it--);
                    }
                }
                else {
                    if(it == m.begin()) break;
                    else it--;
                }
            }
            for(int i=0;i<vadd.size();i++) add(vadd[i].first.first, vadd[i].first.second, vadd[i].second);
        }
        for(int i=0;i<n;i++) cout << ans[i].first << " " << ans[i].second << endl;
    }
    return 0;
}
Example #28
0
inline int get_rank(int i){
  it=l_node.upper_bound(i);
  --it;
  splay(it->second);
  return it->second->ch[0]->sz + i-it->second->l+1;
}
Example #29
0
 void update(int timestamp) {
     auto it = hash.upper_bound(timestamp-300);
     if (it != hash.begin()) {
         hash.erase(hash.begin(), it);
     }
 }
Example #30
0
int main() {
	int n,m;
	cin>>n>>m;
	long long arr[n], sarr[n];
	for (int i=0;i<n;i++) {
		cin>>arr[i];
		sarr[i] = arr[i];
		dumpmap[arr[i]].num_permute = 0;
		dumpmap[arr[i]].innermap[i] = 0;
		/*
		if (dumpmap.find(arr[i]) == dumpmap.end()) {
			dumpmap[arr[i]].freq = 1;
		} else {
			dumpmap[arr[i]].freq++;
		}
		*/
	}
	/*
	long long maxval = -1;
	for (int i=0;i<n;i++) {
		maxval = -1;
		for (int j=i;j<n;j++) {
			maxval = maxf(maxval, arr[j]);
			dumpmap[maxval].num_permute++;
		}
	}
	*/
	sort(sarr, sarr + n, descendingOrder);
	getSubarrayMax(arr, 0, n-1, sarr, 0);

	iter_type tempIter, endIter;
	int tempval;
	long long count = 1;
	/*
	for (iter_type iter = dumpmap.begin(); iter != dumpmap.end(); iter++) {
		tempval = (iter->second).freq;
		(iter->second).num_permute = ((count+tempval-1)*(count+tempval) - (count-1)*count)/2;
		count += tempval;
	}
	*/
	count = 0;
	for (iter_type iter = dumpmap.begin(); iter != dumpmap.end(); iter++) {
		cout<<iter->first<<" "<<(iter->second).num_permute<<endl;
		count += (iter->second).num_permute;
		(iter->second).group_add = count;
	}

	//base_check
	/*
	if ((dumpmap.rbegin()->second).group_add != n*(n+1)/2) {
		while (1) {}
	}
	*/

	char ch, starter;
	long long k;
	while (m--) {
		cin>>ch>>k>>starter;
		if (ch == '=') {
			if (dumpmap.find(k) == dumpmap.end()) {
				if (starter == 'D') {
					cout<<"C";
				} else {
					cout<<"D";
				}
				continue;
			}

			if (dumpmap[k].num_permute%2 == 0) {
				if (starter == 'D') {
					cout<<"C";
				} else {
					cout<<"D";
				}
			} else {
				if (starter == 'D') {
					cout<<"D";
                } else {
            		cout<<"C";
                }
			}
			continue;
		}

		if (ch == '<') {
			tempIter = dumpmap.lower_bound(k);
			if (tempIter == dumpmap.end() || tempIter == dumpmap.begin()) {
				if (starter == 'D') {
					cout<<"C";
				} else {
					cout<<"D";
				}
				continue;
			}
			tempIter--;
			if ((tempIter->second).group_add%2 == 0) {
				if (starter == 'D') {
                    cout<<"C";
                } else {
                    cout<<"D";
                }
			} else {
				if (starter == 'D') {
                    cout<<"D";
                } else {
                    cout<<"C";
                }
			}
			continue;
		}

		if (ch == '>') {
            tempIter = dumpmap.upper_bound(k);
			endIter = dumpmap.end();
			endIter--;
            if (tempIter == dumpmap.end()) {
                if (starter == 'D') {
                    cout<<"C";
                } else {
                    cout<<"D";
                }
                continue;
            }

			long long differ = (endIter->second).group_add - (tempIter->second).group_add;
            if ((differ + (tempIter->second).num_permute)%2 == 0) {
                if (starter == 'D') {
                    cout<<"C";
                } else {
                    cout<<"D";
                }
            } else {
                if (starter == 'D') {
                    cout<<"D";
                } else {
                    cout<<"C";
                }
            }
            continue;
        }
	}
	return 0;
}