QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#399669#2823. 改善生活ucup-team1251Compile Error//C++172.6kb2024-04-26 16:40:552024-04-26 16:40:55

Judging History

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

  • [2024-04-26 16:40:55]
  • 评测
  • [2024-04-26 16:40:55]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define mid ((l + r) >> 1)
// #define int long long
#define lowbit(x) ((x) & (-x))
const int N = 1e6 + 7, M = 207, inf = 0x3f3f3f3f, mod = 1e9 + 7;
ll n, m, mmax;
vector<ll> g[705];
ll t[705], w[705];
ll sum[705], st[705];
void dfs(int x)
{
    st[x] = 1;
    sum[t[x]] += w[x];
    if (t[x] != 1)
    {
        mmax = max(mmax, sum[t[x]] / sum[1]);
    }
    for (int i = 0; i < g[x].size(); i++)
    {
        if (!st[g[x][i]])
        {
            dfs(g[x][i]);
        }
    }
    return;
}
void solve()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        cin >> t[i];
    }
    for (int i = 1; i <= n; i++)
    {
        cin >> w[i];
    }
    for (int i = 1; i <= m; i++)
    {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
    }
    for (int i = 1; i <= n; i++)
    {
        if (t[i] == 1)
        {
            for (int i = 1; i <= n; i++)
            {
                st[i] = sum[i] = 0;
            }
            dfs(i);
        }
    }
    cout << mmax;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    // cin >> T;
    while (T--)
    {
        solve();
    }
    // cout << fixed << setprecision(10) << c << endl;
}#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define mid ((l + r) >> 1)
// #define int long long
#define lowbit(x) ((x) & (-x))
const int N = 1e6 + 7, M = 207, inf = 0x3f3f3f3f, mod = 1e9 + 7;
ll n, m, mmax;
vector<ll> g[705];
ll t[705], w[705];
ll sum[705], st[705];
void dfs(int x)
{
    st[x] = 1;
    sum[t[x]] += w[x];
    if (t[x] != 1)
    {
        mmax = max(mmax, sum[t[x]] / sum[1]);
    }
    for (int i = 0; i < g[x].size(); i++)
    {
        if (!st[g[x][i]])
        {
            dfs(g[x][i]);
        }
    }
    return;
}
void solve()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        cin >> t[i];
    }
    for (int i = 1; i <= n; i++)
    {
        cin >> w[i];
    }
    for (int i = 1; i <= m; i++)
    {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
    }
    for (int i = 1; i <= n; i++)
    {
        if (t[i] == 1)
        {
            for (int i = 1; i <= n; i++)
            {
                st[i] = sum[i] = 0;
            }
            dfs(i);
        }
    }
    cout << mmax;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    // cin >> T;
    while (T--)
    {
        solve();
    }
    // cout << fixed << setprecision(10) << c << endl;
}

Details

answer.code:72:2: error: stray ‘#’ in program
   72 | }#include <bits/stdc++.h>
      |  ^
answer.code:72:3: error: ‘include’ does not name a type
   72 | }#include <bits/stdc++.h>
      |   ^~~~~~~
answer.code:79:11: error: redefinition of ‘const int N’
   79 | const int N = 1e6 + 7, M = 207, inf = 0x3f3f3f3f, mod = 1e9 + 7;
      |           ^
answer.code:8:11: note: ‘const int N’ previously defined here
    8 | const int N = 1e6 + 7, M = 207, inf = 0x3f3f3f3f, mod = 1e9 + 7;
      |           ^
answer.code:79:24: error: redefinition of ‘const int M’
   79 | const int N = 1e6 + 7, M = 207, inf = 0x3f3f3f3f, mod = 1e9 + 7;
      |                        ^
answer.code:8:24: note: ‘const int M’ previously defined here
    8 | const int N = 1e6 + 7, M = 207, inf = 0x3f3f3f3f, mod = 1e9 + 7;
      |                        ^
answer.code:79:33: error: redefinition of ‘const int inf’
   79 | const int N = 1e6 + 7, M = 207, inf = 0x3f3f3f3f, mod = 1e9 + 7;
      |                                 ^~~
answer.code:8:33: note: ‘const int inf’ previously defined here
    8 | const int N = 1e6 + 7, M = 207, inf = 0x3f3f3f3f, mod = 1e9 + 7;
      |                                 ^~~
answer.code:79:51: error: redefinition of ‘const int mod’
   79 | const int N = 1e6 + 7, M = 207, inf = 0x3f3f3f3f, mod = 1e9 + 7;
      |                                                   ^~~
answer.code:8:51: note: ‘const int mod’ previously defined here
    8 | const int N = 1e6 + 7, M = 207, inf = 0x3f3f3f3f, mod = 1e9 + 7;
      |                                                   ^~~
answer.code:80:4: error: redefinition of ‘ll n’
   80 | ll n, m, mmax;
      |    ^
answer.code:9:4: note: ‘ll n’ previously declared here
    9 | ll n, m, mmax;
      |    ^
answer.code:80:7: error: redefinition of ‘ll m’
   80 | ll n, m, mmax;
      |       ^
answer.code:9:7: note: ‘ll m’ previously declared here
    9 | ll n, m, mmax;
      |       ^
answer.code:80:10: error: redefinition of ‘ll mmax’
   80 | ll n, m, mmax;
      |          ^~~~
answer.code:9:10: note: ‘ll mmax’ previously declared here
    9 | ll n, m, mmax;
      |          ^~~~
answer.code:81:12: error: redefinition of ‘std::vector<long long int> g [705]’
   81 | vector<ll> g[705];
      |            ^
answer.code:10:12: note: ‘std::vector<long long int> g [705]’ previously declared here
   10 | vector<ll> g[705];
      |            ^
answer.code:82:4: error: redefinition of ‘ll t [705]’
   82 | ll t[705], w[705];
      |    ^
answer.code:11:4: note: ‘ll t [705]’ previously declared here
   11 | ll t[705], w[705];
      |    ^
answer.code:82:12: error: redefinition of ‘ll w [705]’
   82 | ll t[705], w[705];
      |            ^
answer.code:11:12: note: ‘ll w [705]’ previously declared here
   11 | ll t[705], w[705];
      |            ^
answer.code:83:4: error: redefinition of ‘ll sum [705]’
   83 | ll sum[705], st[705];
      |    ^~~
answer.code:12:4: note: ‘ll sum [705]’ previously declared here
   12 | ll sum[705], st[705];
      |    ^~~
answer.code:83:14: error: redefinition of ‘ll st [705]’
   83 | ll sum[705], st[705];
      |              ^~
answer.code:12:14: note: ‘ll st [705]’ previously declared here
   12 | ll sum[705], st[705];
      |              ^~
answer.code:84:6: error: redefinition of ‘void dfs(int)’
   84 | void dfs(int x)
      |      ^~~
answer.code:13:6: note: ‘void dfs(int)’ previously defined here
   13 | void dfs(int x)
      |      ^~~
answer.code:101:6: error: redefinition of ‘void solve()’
  101 | void solve()
      |      ^~~~~
answer.code:30:6: note: ‘void solve()’ previously defined here
   30 | void solve()
      |      ^~~~~
answer.code:132:8: error: redefinition of ‘int main()’
  132 | signed main()
      |        ^~~~
answer.code:61:8: note: ‘int main()’ previously defined here
   61 | signed main()
      |        ^~~~