QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#592963#7738. Equivalent RewritingflsWA 0ms7652kbC++203.3kb2024-09-27 10:35:562024-09-27 10:35:57

Judging History

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

  • [2024-09-27 10:35:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:7652kb
  • [2024-09-27 10:35:56]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <stack>

template <class T, size_t size = std::tuple_size<T>::value> std::string to_debug(T, std::string s = "") requires(not std::ranges::range<T>);
std::string to_debug(auto x) requires requires(std::ostream& os) { os << x; } { return static_cast<std::ostringstream>(std::ostringstream() << x).str(); }
std::string to_debug(std::ranges::range auto x, std::string s = "") requires(not std::is_same_v<decltype(x), std::string>) {
  for (auto xi : x) { s += ", " + to_debug(xi); }
  return "[" + s.substr(s.empty() ? 0 : 2) + "]";
}
template <class T, size_t size> std::string to_debug(T x, std::string s) requires(not std::ranges::range<T>) {
  [&]<size_t... I>(std::index_sequence<I...>) { ((s += ", " + to_debug(get<I>(x))), ...); }(std::make_index_sequence<size>());
  return "(" + s.substr(s.empty() ? 0 : 2) + ")";
}
#ifndef ONLINE_JUDGE
#define debug(...) std::cerr << __LINE__ << ": (" #__VA_ARGS__ ") = " << to_debug(std::tuple(__VA_ARGS__)) << "\n"
#else
#define debug(x...)
#endif

using i64 = long long;

const int mxn = 1e6+6;

int mx[mxn];

int cnt[mxn];

bool del[mxn];

std::vector <int> p1;

std::set <int> p2;

void solve()
{
#define tests
    int n, m;
    std::cin >> n >> m;
    p1.clear();
    p2.clear();
    for(int i = 1 ; i <= m ; i++){
        mx[i] = cnt[i] = 0;
    }
    for(int pi, i = 1 ; i <= n ; i++){
        del[i] = false;
        std::cin >> pi;
        for(int inp, j = 1 ; j <= pi ; j++){
            std::cin >> inp;
            mx[inp] = i;
            cnt[inp]++;
        }
    }
    for(int i = 1 ; i <= m ; i++){
        if(cnt[i] >= 2){
            p2.insert(mx[i]);
            del[mx[i]] = true;
        }
    }
    //debug(p1);
    for(int i = 1 ; i <= n ; i++){
        if(!del[i]){
            p1.push_back(i);
        }
    }
    //debug(p1);
    if(p1.size() >= 2){
        std::swap(p1[0], p1[1]);
        std::cout << "Yes\n";
        std::vector <int> ans;
        for(auto x : p1)
            ans.push_back(x);
        for(auto x : p2)
            ans.push_back(x);
        for(int i = 0 ; i < n - 1 ; i++)
            std::cout << ans[i] << " ";
        std::cout << ans[n - 1] << "\n";
    }else{
        //std::cout << "No\n";
        if(p1.size() == 1 ){
             std::cout << "Yes\n";
        std::vector <int> ans;
        for(auto x : p1)
            ans.push_back(x);
        for(auto x : p2)
            ans.push_back(x);
        for(int i = 0 ; i < n - 1 ; i++)
            std::cout << ans[i] << " ";
        std::cout << ans[n - 1] << "\n";
        }else{
            std::cout << "No\n";
        }
    }
}
 
signed main()
{
    std::cin.tie(nullptr)->sync_with_stdio(false);
    int _{1};
#ifdef tests
    std::cin >> _;
#endif
    while(_--) solve();
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 7652kb

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
3 1 2
Yes
1 2
Yes
1

result:

wrong answer two transactions are same. (test case 2)