QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#663119#2670. Arranging shoesPioneer#Compile Error//C++201.4kb2024-10-21 13:23:492024-10-21 13:23:50

Judging History

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

  • [2024-10-21 13:23:50]
  • 评测
  • [2024-10-21 13:23:49]
  • 提交

answer

#include "shoes.h"
#include <bits/stdc++.h>

#define sz(s) ((int)s.size())

using namespace std;

const int MAX=1e5+10;

struct segtree{
	int t[4*MAX];
	
	void build(int v,int tl,int tr){
		if(tl==tr){
			t[v]=1;
			return;
		}
		int tm=(tl+tr)/2;
		build(2*v,tl,tm);
		build(2*v+1,tm+1,tr);
		t[v]=t[2*v]+t[2*v+1];
	}

	void update(int v,int tl,int tr,int pos,int x){
		if(tl==tr){
			t[v]+=x;
			return;
		}
		int tm=(tl+tr)/2;
		if(pos<=tm)update(2*v,tl,tm,pos,x);
		else update(2*v+1,tm+1,tr,pos,x);
		t[v]=t[2*v]+t[2*v+1];
	}

	int get(int v,int tl,int tr,int l,int r){
		if(l>r||tl>r||l>tr)return 0;
		if(l<=tl&&tr<=r)return t[v];
		int tm=(tl+tr)/2;
		return get(2*v,tl,tm,l,r)+get(2*v+1,tm+1,tr,l,r);
	}
}t;

set<int> open[MAX],close[MAX];

long long count_swaps(vector<int> S) {
	int n=sz(S);
	t.build(1,0,n-1);
	for(int i=0;i<n;i++){
		S[i]=-S[i];
		if(S[i]>0)open[S[i]].insert(i);
		else close[-S[i]].insert(i);
	}
	long long ans=0;
	for(int i=0;i<n;i++){
		if(t.get(1,0,n-1,i,i)==0)continue;
		if(S[i]>0){
			open[S[i]].erase(i);
			int pos=*close[S[i]].begin();
			close[S[i]].erase(pos);
			ans+=t.get(1,0,n-1,i+1,pos-1);
			t.update(1,0,n-1,pos,-1);
		}
		else{
			S[i]=-S[i];
			close[S[i]].erase(i);
			int pos=*open[S[i]].begin();
			open[S[i]].erase(pos);
			ans+=t.get(1,0,n-1,i,pos-1);
			t.update(1,0,n-1,pos,-1);
		}
	}
	return ans;
}

Details

answer.code:43:29: error: ‘std::set<int> close [100010]’ redeclared as different kind of entity
   43 | set<int> open[MAX],close[MAX];
      |                             ^
In file included from /usr/include/c++/13/bits/atomic_wait.h:44,
                 from /usr/include/c++/13/bits/atomic_base.h:42,
                 from /usr/include/c++/13/bits/shared_ptr_atomic.h:33,
                 from /usr/include/c++/13/memory:81,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:56,
                 from answer.code:2:
/usr/include/unistd.h:353:12: note: previous declaration ‘int close(int)’
  353 | extern int close (int __fd);
      |            ^~~~~
answer.code: In function ‘long long int count_swaps(std::vector<int>)’:
answer.code:51:33: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   51 |                 else close[-S[i]].insert(i);
      |                                 ^
answer.code:51:35: error: request for member ‘insert’ in ‘*(close, (close + ((sizetype)(- S.std::vector<int>::operator[](((std::vector<int>::size_type)i))))))’, which is of non-class type ‘int(int)’
   51 |                 else close[-S[i]].insert(i);
      |                                   ^~~~~~
answer.code:58:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   58 |                         int pos=*close[S[i]].begin();
      |                                            ^
answer.code:58:46: error: request for member ‘begin’ in ‘*(close, (close + ((sizetype)S.std::vector<int>::operator[](((std::vector<int>::size_type)i)))))’, which is of non-class type ‘int(int)’
   58 |                         int pos=*close[S[i]].begin();
      |                                              ^~~~~
answer.code:59:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   59 |                         close[S[i]].erase(pos);
      |                                   ^
answer.code:59:37: error: request for member ‘erase’ in ‘*(close, (close + ((sizetype)S.std::vector<int>::operator[](((std::vector<int>::size_type)i)))))’, which is of non-class type ‘int(int)’
   59 |                         close[S[i]].erase(pos);
      |                                     ^~~~~
answer.code:65:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   65 |                         close[S[i]].erase(i);
      |                                   ^
answer.code:65:37: error: request for member ‘erase’ in ‘*(close, (close + ((sizetype)S.std::vector<int>::operator[](((std::vector<int>::size_type)i)))))’, which is of non-class type ‘int(int)’
   65 |                         close[S[i]].erase(i);
      |                                     ^~~~~