QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#290223#7967. 二进制daydream#Compile Error//C++202.0kb2023-12-24 16:20:412023-12-24 16:20:41

Judging History

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

  • [2023-12-24 16:20:41]
  • 评测
  • [2023-12-24 16:20:41]
  • 提交

answer

#include<bits/stdc++.h>
#define db double
#define LL long long
#define pb push_back
#define eb emplace_back
#define pli pair<LL,int>
#define pii pair<int,int>
#define fr first
#define sc second
#define mp make_pair
using namespace std;
const int dx[]={0,1,0,-1,1,1,-1,-1},
		  dy[]={1,0,-1,0,1,-1,1,-1};

struct BIT
{
	int n;
	vector<int> tr;
	BIT(int N)
	{
		tr.resize((n=N)+10);
	}
	void upd(int i) {for(;i<=n;i+=(i&-i)) tr[i]++;}
	int qry(int i) {int res=0; for(;i;i-=(i&-i)) res+=tr[i]; return res;}
};
int n;
void solve()
{
	cin>>n;
	string s;cin>>s;s=" "+s;
	vector<int> a(n+10),f(n+10),ex(n+10,1),nxt(n+10),pre(n+10),cnt(n*2+10);
	vector<priority_queue<int,vector<int>,greater<int>>> pos(n*2+10),del(n*2+10);
	nxt[n+1]=n+1;nxt[0]=1;pre[n+1]=n;
	for(int i=1;i<=n;++i) a[i]=s[i]-'0',nxt[i]=i+1,pre[i]=i-1;
	BIT T(n);
	for(int k=1,x=1;x<=n;++k,x<<=1)
	{
		int S=(1<<k)-1;
		{
			int p=nxt[0],ps=p,x=0;
			for(int j=1;j<k;++j,ps=nxt[ps]) x=x<<1|a[ps];
			for(;ps<=n;p=nxt[p],ps=nxt[ps])
			{
				x=((x<<1)&S)|a[ps];
				f[p]=x;
				cnt[f[p]]++;pos[f[p]].push(p);
			}
		}
//		cout<<'\n';
		for(int i=x;i<=n&&i<(x<<1);++i)
		{
//			cout<<cnt[7]<<'\n';
			if(!cnt[i])
			{
				cout<<"-1 0\n";
				continue;
			}
			while(pos[i].top()==del[i].top)
			{
				pos[i].pop();
				del[i].pop();
			}
			int P=*pos[i].begin(),p=P;
			cout<<p-T.qry(p)<<' '<<cnt[i]<<'\n';
			for(int j=1;j<=k;++j,p=nxt[p])
			{
				ex[p]=0;
				T.upd(p);
				cnt[f[p]]--;
				del[f[p]].push(p);
			}
			nxt[pre[P]]=p;pre[p]=pre[P];
			p=P;
			for(int j=1;j<k;++j) p=pre[p];
			if(!p) p=nxt[p];
			int x=0,ps=p;
			for(int j=1;j<k;++j,ps=nxt[ps]) x=x<<1|a[ps];
			for(int j=1;j<k;++j,p=nxt[p],ps=nxt[ps])
			{
				cnt[f[p]]--;del[f[p]].push(p);
				if(ps<=n)
				{
					x=((x<<1)&S)|a[ps];
					f[p]=x;
					cnt[f[p]]++;pos[f[p]].push(p);
				}
			}
			pos[i].clear();
			del[i].clear();
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int TT=1;
//	cin>>TT;
	for(;TT;--TT) solve();
	return 0;
}

详细

answer.code: In function ‘void solve()’:
answer.code:58:52: error: invalid use of member function ‘std::priority_queue<_Tp, _Sequence, _Compare>::const_reference std::priority_queue<_Tp, _Sequence, _Compare>::top() const [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>; std::priority_queue<_Tp, _Sequence, _Compare>::const_reference = const int&]’ (did you forget the ‘()’ ?)
   58 |                         while(pos[i].top()==del[i].top)
      |                                                       ()
answer.code:63:39: error: ‘__gnu_cxx::__alloc_traits<std::allocator<std::priority_queue<int, std::vector<int>, std::greater<int> > >, std::priority_queue<int, std::vector<int>, std::greater<int> > >::value_type’ {aka ‘class std::priority_queue<int, std::vector<int>, std::greater<int> >’} has no member named ‘begin’
   63 |                         int P=*pos[i].begin(),p=P;
      |                                       ^~~~~
answer.code:64:31: error: ‘p’ was not declared in this scope
   64 |                         cout<<p-T.qry(p)<<' '<<cnt[i]<<'\n';
      |                               ^
answer.code:88:32: error: ‘__gnu_cxx::__alloc_traits<std::allocator<std::priority_queue<int, std::vector<int>, std::greater<int> > >, std::priority_queue<int, std::vector<int>, std::greater<int> > >::value_type’ {aka ‘class std::priority_queue<int, std::vector<int>, std::greater<int> >’} has no member named ‘clear’
   88 |                         pos[i].clear();
      |                                ^~~~~
answer.code:89:32: error: ‘__gnu_cxx::__alloc_traits<std::allocator<std::priority_queue<int, std::vector<int>, std::greater<int> > >, std::priority_queue<int, std::vector<int>, std::greater<int> > >::value_type’ {aka ‘class std::priority_queue<int, std::vector<int>, std::greater<int> >’} has no member named ‘clear’
   89 |                         del[i].clear();
      |                                ^~~~~