QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#690433 | #8237. Sugar Sweet II | CMing | Compile Error | / | / | C++14 | 1.2kb | 2024-10-30 22:09:18 | 2024-10-30 22:09:19 |
Judging History
你现在查看的是最新测评结果
- [2024-11-04 16:59:03]
- hack成功,自动添加数据
- (/hack/1109)
- [2024-10-30 22:09:19]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-10-30 22:09:18]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define int LL
const int N = 5e5 + 5;
int a[N], b[N], w[N];
int p[N];
const int mod = 1e9 + 7;
int f[N];
int n;
LL qmi(LL x, LL k)
{
LL res = 1;
while(k)
{
if(k & 1) res = res * x % mod;
k >>= 1;
x = x * x % mod;
}
return res % mod;
}
bool st[N];
void dfs(int u)
{
st[u] = true;
int j = b[u];
if(a[u] < a[j]) p[u] = 1;
else if(a[u] >= a[j] + w[j]) p[u] = 0;
else if(j == u) p[u] = 0;
else
{
if(!st[j]) dfs(j);
p[u] = p[j] ? p[j] + 1 : 0;
}
}
void solve()
{
cin >> n;
for(int i = 1; i <= n; i++) cin >> a[i], st[i] = false, p[i] = 0;
for(int i = 1; i <= n; i++) cin >> b[i];
for(int i = 1; i <= n; i++) cin >> w[i];
for(int i = 1; i <= n; i++)
{
if(!st[i]) dfs(i);
// cout << p[i] << " ";
LL t = 0;
if(p[i]) t = qmi(f[p[i]], mod - 2);
cout << (a[i] + t * w[i] % mod) % mod << " ";
}
cout << "\n";
}
int main()
{
f[0] = 1;
for(int i = 1; i < N; i++) f[i] = f[i - 1] * i % mod;
int t; cin >> t;
while(t--)
solve();
}
Details
answer.code:4:13: error: ‘::main’ must return ‘int’ 4 | #define int LL | ^~ answer.code:55:1: note: in expansion of macro ‘int’ 55 | int main() | ^~~