QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#410738#7738. Equivalent RewritingRhyme3Compile Error//C++171.3kb2024-05-14 13:40:372024-05-14 13:40:38

Judging History

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

  • [2024-05-14 13:40:38]
  • 评测
  • [2024-05-14 13:40:37]
  • 提交

answer

#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long 
#define sz(a) ((int)(a).size())
#define For(i, a, n) for(int i = a; i <= n; i++)
#define rof(i, n, a) for(int i = n; i >= a; i--)
#define endl "\n"
using namespace std;
const int maxn = 1e5 + 5;
int T;
int n, m, p, x, ans;
void solve()
{
    cin >> n >> m;
    vector<int> a(maxn);
    set<int> g[maxn];
    vector<set<int>> s(n+1);
    ans = 0;
    For(i, 1, n)
    {
        cin >> p;
        For(j, 1, p)
        {
            cin >> x;
            a[x] = i;
            g[i].insert(x);
        }
    }
    For(i, 1, m)
    {
        if(a[i] > 1 && g[a[i] - 1].count(i))
        {
            v[a[i]] = true;
        }
    }
    For(i, 2, n)
    {
        if(!v[i]) 
        {
            ans = i;
            break;
        }
    }
    if(ans)
    {
        cout << "Yes" << endl;
        For(i, 1, n)
        {
            if(i == ans - 1) cout << ans;
            else if(i == ans) cout << ans - 1;
            else cout << i;
            cout << (i == n ? "\n" : " ");
        }
    }
    else cout << "No" << endl;
    return;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> T;
    //T = 1;
    For(I, 1, T)
    {
        solve();
    }
    return 0;
}

详细

answer.code: In function ‘void solve()’:
answer.code:33:13: error: ‘v’ was not declared in this scope
   33 |             v[a[i]] = true;
      |             ^
answer.code:38:13: error: ‘v’ was not declared in this scope
   38 |         if(!v[i])
      |             ^