Submission #136282

# Submission time Handle Problem Language Result Execution time Memory
136282 2019-07-25T05:35:40 Z 김현수(#3358) Queue (CEOI06_queue) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;

typedef pair<int,int> pii;
const int N = 50005, inf = 1e9+7;

map<int, int> fr, bk, s[2];

int getfr (int I) {
	if(fr.find(I) == fr.end()) return I-1;
	return fr[I];
}

int getbk (int I) {
	if(bk.find(I) == bk.end()) return I+1;
	return bk[I];
}

int main()
{
	int n, q, CT = 1;
	scanf("%d",&n);
	int CT = 1;
	while(n--) {
		int A, B;
		scanf("%d%d",&A,&B);
		int AF = getfr(A), AB = getbk(A), BF = getfr(B);
		if(A == B || AB == B) continue;
		fr[AB] = AF;
		bk[AF] = AB;
		fr[A] = BF;
		bk[BF] = A;
		fr[B] = A;
		bk[A] = B;
		if(CT == A) CT = AB;
		if(CT == B) CT = A;
	}
	bk[inf] = inf;
	for(int i=CT,j=1;i<inf;) {
		auto it = bk.lower_bound(i);
		int E = (*it).X;
		j += E-i;
		s[0][E] = j;
		s[1][j] = E;
		i = (*it).Y;
		j++;
	}
	scanf("%d",&q);
	while(q--) {
		char T[2]; int A;
		scanf("%s%d",T,&A);
		auto it = s[T[0]=='L'].lower_bound(A);
		printf("%d\n", (*it).Y - (*it).X + A);
	}
}

Compilation message

queue.cpp: In function 'int main()':
queue.cpp:25:6: error: redeclaration of 'int CT'
  int CT = 1;
      ^~
queue.cpp:23:12: note: 'int CT' previously declared here
  int n, q, CT = 1;
            ^~
queue.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
queue.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&A,&B);
   ~~~~~^~~~~~~~~~~~~~
queue.cpp:50:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&q);
  ~~~~~^~~~~~~~~
queue.cpp:53:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s%d",T,&A);
   ~~~~~^~~~~~~~~~~~~