QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#702493#7738. Equivalent Rewritingjkzj456789Compile Error//C++202.1kb2024-11-02 16:06:142024-11-02 16:06:14

Judging History

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

  • [2024-11-02 16:06:14]
  • 评测
  • [2024-11-02 16:06:14]
  • 提交

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";
}
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;
}

详细

answer.code:12:1: error: ‘vector’ does not name a type
   12 | vector<int> all[100010];
      | ^~~~~~
answer.code: In function ‘void solve()’:
answer.code:25:9: error: ‘all’ was not declared in this scope; did you mean ‘ll’?
   25 |         all[i].clear(), p[i] = 0;
      |         ^~~
      |         ll
answer.code:27:5: error: ‘vector’ was not declared in this scope
   27 |     vector<int> last(m + 1, 0);
      |     ^~~~~~
answer.code:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
    2 | #include <iostream>
  +++ |+#include <vector>
    3 | //  #include <bits/stdc++.h>
answer.code:27:12: error: expected primary-expression before ‘int’
   27 |     vector<int> last(m + 1, 0);
      |            ^~~
answer.code:35:13: error: ‘all’ was not declared in this scope; did you mean ‘ll’?
   35 |             all[i].push_back(x);
      |             ^~~
      |             ll
answer.code:36:13: error: ‘last’ was not declared in this scope
   36 |             last[x] = i;
      |             ^~~~
answer.code:41:14: error: ‘all’ was not declared in this scope; did you mean ‘ll’?
   41 |         sort(all[i].begin(), all[i].end());
      |              ^~~
      |              ll
answer.code:41:9: error: ‘sort’ was not declared in this scope; did you mean ‘short’?
   41 |         sort(all[i].begin(), all[i].end());
      |         ^~~~
      |         short
answer.code:45:23: error: ‘all’ was not declared in this scope; did you mean ‘ll’?
   45 |         for (auto c : all[i])
      |                       ^~~
      |                       ll
answer.code:48:17: error: ‘last’ was not declared in this scope
   48 |             if (last[c]==i && (pos < all[i - 1].size() && all[i - 1][pos] == c))
      |                 ^~~~