답안 #335781

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
335781 2020-12-14T02:30:21 Z Mo_TOI_I_am_Garbage Bubble Sort 2 (JOI18_bubblesort2) C++14
컴파일 오류
0 ms 0 KB
#include "bubblesort2.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> countScans(vector<int> A, vector<int> X, vector<int> V)
{
	int ans = 0;
	for(int i=1; i < (int)A.size(); i ++)
		if(A[i] < A[i - 1]) ans ++;
	vector<int> res;
	for(int i=0; i < (int)X.size(); i ++)
	{
		if(X[i] > 0 && A[X[i]] < A[X[i] - 1]) ans --;
		if(X[i] < (int)A.size() - 1 && A[X[i]] > A[X[i] + 1]) ans --;
		A[X[i]] = V[i];
		if(X[i] > 0 && A[X[i]] < A[X[i] - 1]) ans ++;
		if(X[i] < (int)A.size() - 1 && A[X[i]] > A[X[i] + 1]) ans ++;
		res.push_back(ans);
	}
	return res;
}


int readInt(){
	int i;
	if(scanf("%d",&i)!=1){
		fprintf(stderr,"Error while reading input\n");
		exit(1);
	}
	return i;
}

int main(){
	int N,Q;
	N=readInt();
	Q=readInt();
	
	std::vector<int> A(N);
	for(int i=0;i<N;i++)
		A[i]=readInt();
	
	std::vector<int> X(Q),V(Q);
	for(int j=0;j<Q;j++){
		X[j]=readInt();
		V[j]=readInt();
	}

	std::vector<int> res=countScans(A,X,V);
	

	for(int j=0;j<int(res.size());j++)
		printf("%d\n",res[j]);
}

Compilation message

/tmp/cceL4oxv.o: In function `readInt()':
grader.cpp:(.text+0x0): multiple definition of `readInt()'
/tmp/ccvDgFsB.o:bubblesort2.cpp:(.text+0x2d0): first defined here
/tmp/cceL4oxv.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccvDgFsB.o:bubblesort2.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status