QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#618044#7738. Equivalent RewritingasaltfishWA 1ms7812kbC++231.8kb2024-10-06 18:18:072024-10-06 18:18:08

Judging History

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

  • [2024-10-06 18:18:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7812kb
  • [2024-10-06 18:18:07]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string.h>
#include<iomanip>
#include<stack>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<set>
#define ll               long long
#define endl             "\n"
using namespace std;
inline int read() { register int s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-')w = -1; ch = getchar(); }while (ch >= '0' && ch <= '9')s = s * 10 + ch - '0', ch = getchar(); return s * w; }
ll t, q, n, a[200005], b[200005], p, num[200005], c[200005], d[200005], up[200005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> t;
    while (t--)
    {
        cin >> q >> n;
        for (int i = 1; i <= q; i++)
        {
            cin >> num[i];
            for (int j = 1; j <= num[i]; j++)
            {
                cin >> p;
                b[p] = a[p];
                a[p] = i;
            }
        }
        for (int i = 1; i <= n; i++)
        {
            c[a[i]]++;
            d[a[i]] = max(b[i], d[a[i]]);
        }
        bool flag=0;
        for(int i=2;i<=q;i++)
        {
            if(d[i]!=i-1)
            {
                flag=1;
                cout<<"Yes"<<endl;
                for(int j=1;j<=q;j++)
                {
                    if(j==i-1)
                        cout<<j+1;
                    else if(j==i)
                        cout<<j-1;
                    else cout<<j;
                    if(j!=n)cout<<" ";
                }
            }
        }
        if (!flag)cout << "No";
        if (t)cout << endl;
        for (int i = 1; i <= max(n,q); i++)
        {
            a[i] = b[i] = c[i] = d[i] = num[i] = 0;
        }
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 7672kb

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
No

result:

ok OK. (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 7812kb

input:

1
10 5
2 2 4
4 1 3 4 2
1 2
3 2 1 4
4 5 2 4 3
3 2 5 4
3 5 4 2
3 1 3 2
5 1 4 2 3 5
1 4

output:

Yes
2 1 3 4 56 7 8 9 10 Yes
1 3 2 4 56 7 8 9 10 Yes
1 2 4 3 56 7 8 9 10 Yes
1 2 3 5 46 7 8 9 10 Yes
1 2 3 4 65 7 8 9 10 Yes
1 2 3 4 57 6 8 9 10 Yes
1 2 3 4 56 8 7 9 10 

result:

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