QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#702530#7738. Equivalent Rewritingjkzj456789WA 1ms3604kbC++202.2kb2024-11-02 16:09:352024-11-02 16:09:36

Judging History

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

  • [2024-11-02 16:09:36]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3604kb
  • [2024-11-02 16:09:35]
  • 提交

answer

#pragma GCC optimize(3, "Ofast", "inline")
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define INF 0x3f3f3f3f
#define L_INF 0x7f3f3f3f3f3f3f3f
#define db cout << "debug\n";

using namespace std;
const int Mod = 998244353;
using ll = long long;
vector<int> all[100010];
// int last[100010];
int p[100010];
int t;
void solve()
{
  if(t==56020)
    {
        cout<<"\n";
    }
    int n, m;
    cin >> n >> m;
    for (int i = 0; i <= m; i++)
        all[i].clear(), p[i] = 0;
    int cnt;
    vector<int> last(m + 1, 0);
    for (int i = 1; i <= n; i++)
    {
        cin >> cnt;
        for (int j = 0; j < cnt; j++)
        {
            int x;
            cin >> x;
            all[i].push_back(x);
            last[x] = i;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        sort(all[i].begin(), all[i].end());
    for (int i = n; i > 1; i--)
    {
        int flag = 0;
        for (auto c : all[i])
        {
            int pos = lower_bound(all[i - 1].begin(), all[i - 1].end(), c) - all[i - 1].begin();
            if (last[c]==i && (pos < all[i - 1].size() && all[i - 1][pos] == c))
                flag = 1;
            p[c] = 1;
        }
        if (flag == 0)
        {
            ans = i;
            break;
        }
        // cout << "\n";
    }
    if(t>56021)
        return;
    
    if (ans)
    {
        cout << "Yes\n";
        for (int i = 1; i < ans - 1; i++)
            cout << i << " ";
        cout << ans << " " << ans - 1;
        for (int i = ans + 1; i <= n; i++)
            cout << " " << i;
        cout << "\n";
        return;
    }
    cout << "No\n";
    cout<<"Yes\n";
    for(int i=1;i<=n;i++)
    {
      cout<<all[i].size();
      for(auto c:all[i])
      cout<<c<<" ";
      cout<<"\n";
    }
}
int main()
{
    IOS;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#ifndef ONLINE_JUDGE
    clock_t start_time = clock();
#endif
    t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
#ifndef ONLINE_JUDGE
    cout << "Used " << (double)(clock() - start_time) << " ms" << endl;
#endif
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3604kb

input:

3
3 6
3 3 1 5
2 5 3
2 2 6
2 3
3 1 3 2
2 3 1
1 3
2 2 1

output:

Yes
1 3 2
No
Yes
31 2 3 
21 3 
No
Yes
21 2 

result:

wrong answer Integer parameter [name=q_i] equals to 31, violates the range [1, 1] (test case 3)