QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#283805#7738. Equivalent Rewritingckiseki#WA 0ms3840kbC++201.5kb2023-12-15 15:16:572023-12-15 15:16:58

Judging History

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

  • [2023-12-15 15:16:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3840kb
  • [2023-12-15 15:16:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define orange(a...) orange_(#a, a)
#define debug(a...) debug_(#a, a)
#include <experimental/iterator>
void debug_(auto s, auto ...a) {
  cerr << "\e[1;32m(" << s << ") = (";
  int f = 0;
  (..., (cerr << (f++ ? ", " : "") << a));
  cerr << ")\e[0m\n";
}
void orange_(auto s, auto L, auto R) {
  cerr << "\e[1;33m[ " << s << " ] = [ ";
  using namespace experimental;
  copy(L, R, make_ostream_joiner(cerr, ", "));
  cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> ops;
    for (int i = 0; i < n; ++i) {
      int l;
      cin >> l;
      vector<int> cur(l);
      for (auto &x : cur)
        cin >> x;
      sort(cur.begin(), cur.end());
      ops.push_back(cur);
    }
    bool ok = false;
    vector<int> ans(n);
    iota(all(ans), 1);
    for (int i = 1; i < n; ++i) {
      bool no = true;
      for (int x : ops[i]) {
        no &= not ranges::binary_search(ops[i - 1], x);
      }
      if (no) {
        ok = true;
        swap(ans[i], ans[i - 1]);
        break;
      }
    }
    if (not ok) {
      cout << "No\n";
      continue;
    }
    cout << "Yes\n";
    for (int i = 0; i < n; ++i) {
      cout << ans[i] << " \n"[i + 1 == n];
    }
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3840kb

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: 3688kb

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:

No

result:

wrong answer jury found an answer but participant did not (test case 1)