QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#351117#2645. CollapseltunjicCompile Error//C++141.4kb2024-03-11 16:06:352024-03-11 16:06:36

Judging History

你现在查看的是最新测评结果

  • [2024-03-11 16:06:36]
  • 评测
  • [2024-03-11 16:06:35]
  • 提交

answer

#include <vector> 
#include <algorithm>
#include <cstdio> 

using namespace std; 

typedef long long ll;
typedef vector<int> vi;

const int LOG = 17;
const int N = 1 << LOG; 

int F[N]; 

void add(int x, int val) { 
	for(; x < N; x += x & -x) F[x] += val;
}

int sum(int x) {
	int ret = 0;
	for(; x; x -= x & -x) ret += F[x]; 
	return ret;
}

vi simulateCollapse(int n, vi T, vi X, vi Y, vi W, vi P) {
	vi ANS(W.size());
	vi I(W.size());

	for(int i = 0; i < (int) T.size(); ++i) {
		++X[i];
		++Y[i];
		if(X[i] > Y[i]) swap(X[i], Y[i]);
	}

	for(int i = 0; i < W.size(); ++i) I[i] = i, ++P[i];
	sort(I.begin(), I.end(), [&W](int a, int b) { return W[a] < W[b]; }); 

	int e = 0;
	for(int j = 0, k = 0; k < W.size(); ++k) {
		int i = I[k];
		for(; j <= W[i]; ++j) {
			int x = T[j] ? -1 : 1;
			e += x;
//			printf("[%d, %d] += %d\n", X[j], Y[j], x);
			add(X[j], x);
			add(Y[j], -x);
		}
//		printf("ANS[%d] = %d (%d)\n", i, n - e + sum(P[i]), sum(P[i]));
		ANS[i] = n - (e - sum(P[i]));
	}
	return ANS;
}

int main() {
	int n, m, q;
	scanf("%d%d%d", &n, &m, &q); 

	vi T(m), X(m), Y(m), W(q), P(q);
	for(int i = 0; i < m; ++i) scanf("%d%d%d", &T[i], &X[i], &Y[i]); 
	for(int i = 0; i < q; ++i) scanf("%d%d", &W[i], &P[i]); 

	vi ANS = simulateCollapse(n, T, X, Y, W, P);

	for(int x : ANS) printf("%d ", x);
	printf("\n");
	return 0;
}

Details

implementer.cpp: In function ‘int main(int, char**)’:
implementer.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d%d%d", &N, &C, &Q);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
implementer.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |                 scanf("%d%d%d", &T[i], &X[i], &Y[i]);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
implementer.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |                 scanf("%d%d", &W[i], &P[i]);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:56:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   56 |         scanf("%d%d%d", &n, &m, &q);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
answer.code:59:41: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   59 |         for(int i = 0; i < m; ++i) scanf("%d%d%d", &T[i], &X[i], &Y[i]);
      |                                    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:60:41: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   60 |         for(int i = 0; i < q; ++i) scanf("%d%d", &W[i], &P[i]);
      |                                    ~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccpRkJiT.o: in function `main':
answer.code:(.text.startup+0x0): multiple definition of `main'; /tmp/ccRWb5bT.o:implementer.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status