QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#592952 | #7738. Equivalent Rewriting | fls | Compile Error | / | / | C++14 | 3.3kb | 2024-09-27 10:32:28 | 2024-09-27 10:32:29 |
Judging History
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 && p1[0] != 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;
}
详细
answer.code:27:105: error: ‘requires’ only available with ‘-std=c++20’ or ‘-fconcepts’ 27 | 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>); | ^~~~~~~~ answer.code:27:123: error: ‘std::ranges’ has not been declared 27 | 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>); | ^~~~~~ answer.code:27:138: error: expected primary-expression before ‘>’ token 27 | 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>); | ^ answer.code:27:139: error: expected primary-expression before ‘)’ token 27 | 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>); | ^ answer.code:28:22: warning: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’ 28 | std::string to_debug(auto x) requires requires(std::ostream& os) { os << x; } { return static_cast<std::ostringstream>(std::ostringstream() << x).str(); } | ^~~~ answer.code:28:30: error: ‘requires’ only available with ‘-std=c++20’ or ‘-fconcepts’ 28 | std::string to_debug(auto x) requires requires(std::ostream& os) { os << x; } { return static_cast<std::ostringstream>(std::ostringstream() << x).str(); } | ^~~~~~~~ answer.code:28:60: error: expected primary-expression before ‘&’ token 28 | std::string to_debug(auto x) requires requires(std::ostream& os) { os << x; } { return static_cast<std::ostringstream>(std::ostringstream() << x).str(); } | ^ answer.code:28:62: error: ‘os’ was not declared in this scope; did you mean ‘cos’? 28 | std::string to_debug(auto x) requires requires(std::ostream& os) { os << x; } { return static_cast<std::ostringstream>(std::ostringstream() << x).str(); } | ^~ | cos answer.code:28:39: error: there are no arguments to ‘requires’ that depend on a template parameter, so a declaration of ‘requires’ must be available [-fpermissive] 28 | std::string to_debug(auto x) requires requires(std::ostream& os) { os << x; } { return static_cast<std::ostringstream>(std::ostringstream() << x).str(); } | ^~~~~~~~ answer.code:28:39: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated) answer.code: In function ‘std::string to_debug(auto:1)’: answer.code:28:68: error: ‘os’ was not declared in this scope; did you mean ‘cos’? 28 | std::string to_debug(auto x) requires requires(std::ostream& os) { os << x; } { return static_cast<std::ostringstream>(std::ostringstream() << x).str(); } | ^~ | cos answer.code:28:77: warning: no return statement in function returning non-void [-Wreturn-type] 28 | std::string to_debug(auto x) requires requires(std::ostream& os) { os << x; } { return static_cast<std::ostringstream>(std::ostringstream() << x).str(); } | ^ answer.code: At global scope: answer.code:28:79: error: expected unqualified-id before ‘{’ token 28 | std::string to_debug(auto x) requires requires(std::ostream& os) { os << x; } { return static_cast<std::ostringstream>(std::ostringstream() << x).str(); } | ^ answer.code:29:27: error: ‘std::string to_debug’ redeclared as different kind of entity 29 | std::string to_debug(std::ranges::range auto x, std::string s = "") requires(not std::is_same_v<decltype(x), std::string>) { | ^~~~~~ answer.code:28:13: note: previous declaration ‘template<class auto:1> std::string to_debug(auto:1)’ 28 | std::string to_debug(auto x) requires requires(std::ostream& os) { os << x; } { return static_cast<std::ostringstream>(std::ostringstream() << x).str(); } | ^~~~~~~~ answer.code:29:27: error: ‘st...