QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#734419#8237. Sugar Sweet IIRain1Compile Error//C++171.1kb2024-11-11 10:18:592024-11-11 10:18:59

Judging History

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

  • [2024-11-11 10:18:59]
  • 评测
  • [2024-11-11 10:18:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 5e5+5,mod = 1e9+7;
int a[N],b[N],w[N],sta[N],vis[N],dep[N],fac[N],Inv[N];
int T,n;
inline int fastpow(int x,int y) {
	int z = 1;
	for(y;y>>=1,x=1ll*x*x%mod)
		if(y&1) z = 1ll * z * x % mod;
	return z;
}
void dfs(int u) {
	if(vis[u]) {
		if(sta[u] == -1) sta[u] = 0;
		return;
	}
	vis[u] = 1;
	if(sta[u] != -1) return;
	dfs(b[u]);
	sta[u] = sta[b[u]];
	dep[u] = dep[b[u]] + 1;
}
int main() {
	dep[0] = Inv[0] = 1;
	for(int i = 1;i <= 500000;i ++ ) Inv[i] = fastpow(fac[i] = 1ll * fac[i-1] * i % mod,mod - 2);
	for(cin>>T;T;T--) {
		scanf("%d",&n);
		for(int i = 1;i <= n;i ++ ) scanf("%d",&a[i]);
		for(int i = 1;i <= n;i ++ ) scanf("%d",&b[i]);
		for(int i = 1;i <= n;i ++ ) scanf("%d",&w[i]);
		for(int i = 1;i <= n;i ++ ) {
			sta[i] = -1;vis[i] = dep[i] = 0;
			if(a[i] < a[b[i]]) sta[i] = 1,dep[i] = 1;
			if(a[i] >= a[b[i]] + w[b[i]]) sta[i] = 0; 
		}
		for(int i = 1;i <= n;i ++ ) 
			if(!vis[i]) dfs(i);
		for(int i = 1;i <= n;i ++ ) 
			if(sta[i] != 1) printf("%d ",a[i]);
			else printf("%d ",(a[i] + 1ll * w[i] * Inv[dep[i]]) % mod);
		puts("");
	}
}

詳細信息

answer.code: In function ‘int fastpow(int, int)’:
answer.code:8:34: error: expected ‘;’ before ‘)’ token
    8 |         for(y;y>>=1,x=1ll*x*x%mod)
      |                                  ^
      |                                  ;
answer.code: In function ‘int main()’:
answer.code:40:39: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
   40 |                         else printf("%d ",(a[i] + 1ll * w[i] * Inv[dep[i]]) % mod);
      |                                      ~^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                       |                                     |
      |                                       int                                   long long int
      |                                      %lld
answer.code:27:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |                 scanf("%d",&n);
      |                 ~~~~~^~~~~~~~~
answer.code:28:50: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |                 for(int i = 1;i <= n;i ++ ) scanf("%d",&a[i]);
      |                                             ~~~~~^~~~~~~~~~~~
answer.code:29:50: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |                 for(int i = 1;i <= n;i ++ ) scanf("%d",&b[i]);
      |                                             ~~~~~^~~~~~~~~~~~
answer.code:30:50: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |                 for(int i = 1;i <= n;i ++ ) scanf("%d",&w[i]);
      |                                             ~~~~~^~~~~~~~~~~~