QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#508454#7660. Investigating Frog Behaviour on Lily Pad PatternsAu_GoldCompile Error//C++201.3kb2024-08-07 15:45:372024-08-07 15:45:38

Judging History

This is the latest submission verdict.

  • [2024-08-07 15:45:38]
  • Judged
  • [2024-08-07 15:45:37]
  • Submitted

answer

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<string>
#include<iomanip>
#include<cmath>
#include<set>
using namespace std;
using ll = long long;
#define int ll

const int mxn = 1e6 + 2e5 + 5;

set<int> s;
map<int, int> m;
int fp[mxn];

void solve()
{
    int n, q, maxn = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> fp[i];
        m[fp[i]]++;
        maxn = max(maxn, fp[i]);
    }
    for (int i = 1; i <= maxn; i++)
    {
        if (!m[i])//有青蛙
        {
            s.insert(i);
        }
    }
    int q;
    cin >> q;
    while (q--)
    {
        int idx;//青蛙编号
        cin >> idx;
        auto p = s.upper_bound(fp[idx]);//位置
        if (p == s.end())//没有
        {
            s.insert(fp[idx]);
            maxn++;//到maxn+1
            cout << maxn << endl;
            fp[idx] = maxn;//更新位置
        }
        else
        {
            int t = *p;
            cout << t << endl;
            s.erase(p);//删空位
            s.insert(fp[idx]);
            fp[idx] = t;
        }        
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int T = 1;
    //cin >> T;
    while (T--)
    {
        solve();
    }

    return 0;
}

詳細信息

answer.code: In function ‘void solve()’:
answer.code:37:9: error: redeclaration of ‘ll q’
   37 |     int q;
      |         ^
answer.code:22:12: note: ‘ll q’ previously declared here
   22 |     int n, q, maxn = 0;
      |            ^