QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#720913#8237. Sugar Sweet IIStayAloneCompile Error//C++142.3kb2024-11-07 14:40:482024-11-07 14:40:49

Judging History

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

  • [2024-11-07 14:40:49]
  • 评测
  • [2024-11-07 14:40:48]
  • 提交

answer

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return 1ll * a * b / gcd(a, b); }
ll divCeil(ll x, ll y) { return x / y + (x % y != 0); }
const int MAXN = 2e5 + 5;
const double pi = 3.14159265358979323846;
const ll inf = 1e18;
double eps = 1e-9;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
#define endl "\n"
#define int long long
ll inv(ll x)
{
    ll y = mod - 2, ans = 1;
    while (y)
    {
        if (y & 1) (ans *= x) %= mod;
        (x *= x) %= mod;
        y >>= 1;
    }
    return ans;
}
void solve() {
    int n;
    cin >> n;
    vector<int>a(n + 5);
    vector<int>b(n + 5);
    vector<int>w(n + 5);
    vector<int>ok(n + 5, 1);
    vector<int>sz(n + 5, n);// 前面有多少个点
    vector<int>deg(n + 5);
    vector<int>vis(n + 5);
    vector<int>fac(n + 5);
    fac[0] = 1;

    for (int i = 1; i <= n; i++)cin >> a[i];
    for (int i = 1; i <= n; i++)cin >> b[i];
    for (int i = 1; i <= n; i++) {
        cin >> w[i];
        fac[i] = fac[i - 1] * i % mod;
    }
    vector<vector<int>>g(n + 5);
    for (int i = 1; i <= n; i++) {
        if (a[i] >= a[b[i]] + w[b[i]] || b[i] == i)ok[i] = 0;//这个点永远启动不了
        else if (a[i] < a[b[i]])continue;
        else g[b[i]].push_back(i), deg[i]++;
    }
    queue<int>q;
    for (int i = 1; i <= n; i++) {
        if (!deg[i])q.push(i),sz[i] = 1;
    }
    while (!q.empty()) {
        auto u = q.front();
        q.pop();
        vis[u] = 1;
        for (auto x : g[u]) {
            if (!vis[x]) {
                q.push(x);
                sz[x] = sz[u] + 1;
                ok[x] = ok[u];
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        int ans = ok[i]*w[i];
        ans *= inv(fac[sz[i]]);
        ans %= mod;
        ans = (a[i] + ans) % mod;
        cout << ans << " ";
        if (ans == 41666668) {
        	for (auto v : a) cout << v << ' ';
        	for (auto v : b) cout << v << ' ';
        	for (auto v : w) cout << v << ' ';
        	return 0;
		}
    }
    cout << endl;
    return;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    while (t--)solve();
    return 0;
}

詳細信息

answer.code: In function ‘void solve()’:
answer.code:78:24: error: return-statement with a value, in function returning ‘void’ [-fpermissive]
   78 |                 return 0;
      |                        ^