QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#672814#8237. Sugar Sweet IIFluoresceCompile Error//C++202.1kb2024-10-24 19:16:262024-10-24 19:16:27

Judging History

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

  • [2024-11-04 16:59:03]
  • hack成功,自动添加数据
  • (/hack/1109)
  • [2024-10-24 19:16:27]
  • 评测
  • [2024-10-24 19:16:26]
  • 提交

answer

#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define debug(a) cout<<a<<'\n'
#define Pll pair<ll,ll>
#define PII pair<int,int>
#define ft first
#define sd second
#define vec vector
#define pushk push_back
#define ump unordered_map
#define pl p<<1
#define pr p<<1|1
using namespace std;
const int N = 6e5 + 10, M = 1e4 + 10, mod = 1e9+7;
const ll inf = 1e18;
const ld eps = 1e-13;
int mov[4][2] = { {0,1},{1,0},{-1,0},{0,-1} }, dx, dy, _ = 1, __ = 1;
void bout(bool f) {
	if (f)cout << "YES\n";
	else cout << "NO\n";
}
ll n, m, k;
ll a[N],b[N],w[N],inv[N];
bool st[N];

int h[N],ne[N],e[N],idx;
void link(int x,int y){
	e[++idx]=y;
	ne[idx]=h[x];
	h[x]=idx;
}

ll dp[N];

void exgcd(ll a,ll b,ll&x,ll&y){
	if(!b){
		x=a;
		y=0;
		return;
	}
	exgcd(b,a%b,y,x);
	y-=a/b*x;
}

void ini() {
	ll x,y;
	for(int i=1;i<N;++i){
		exgcd(i,mod,x,y);
		inv[i]=x;
	}
	for(int i=2;i<N;++i)inv[i]=inv[i]*inv[i-1]%mod;
}
void solve() {
	cin>>n;
	memset(h,-1,4*(n+2));idx=0;
	memset(st,0,(n+2));
	memset(p,0,8*(n+2));
	for(int i=1;i<=n;++i)cin>>a[i];
	queue<int> q;
	ll x,y,u;
	for(int i=1;i<=n;++i){
		cin>>b[i];
		link(b[i],i);//re
		if(a[i]<a[b[i]]){
			dp[i]=1;//定序数目 
			q.push(i);
		}else if(b[i]==i){
			dp[i]=0;
			q.push(i);
		}
	}
	for(int i=1;i<=n;++i)cin>>w[i];
	while(!q.empty()){
		u=q.front();
		q.pop();
		st[u]=1;
		for(int i=h[u];~i;i=ne[i]){
			int v=e[i];
			if(!st[v]){
				if(a[v]<a[u])dp[v]=1;
				else if(a[v]<a[u]+w[u]&&dp[u])dp[v]=dp[u]+1;
				else dp[v]=0;
				q.push(v);
			}
		}
	}
	for(int i=1;i<=n;++i){
		x=a[i]+w[i]*inv[dp[i]];
		x=(x%mod+mod)%mod;
		cout<<x<<' ';	
	}
	cout<<'\n';
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	streambuf *cinbp=cin.rdbuf(),*coutbp=cout.rdbuf();
	ifstream fin("in.txt");
	ofstream fout("out.txt");	
	cin.rdbuf(fin.rdbuf());
	cout.rdbuf(fout.rdbuf());
#endif
	cin >> _;
	__ = _;
	ini();
	while (_--) {
		solve();
	}
	return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:61:16: error: ‘p’ was not declared in this scope
   61 |         memset(p,0,8*(n+2));
      |                ^