QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#634291#7738. Equivalent Rewritingjr_zlw#Compile Error//C++172.1kb2024-10-12 17:01:162024-10-12 17:01:18

Judging History

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

  • [2024-10-12 17:01:18]
  • 评测
  • [2024-10-12 17:01:16]
  • 提交

answer

jr_zlw:
10 50 1
44 182173741
38 163268500
36 114173760
30 521894533
25 89514235
12 516184197
42 971377551
35 28242326
31 480227821
31 388523197

林宇凡:
#include<bits/stdc++.h>
using namespace std;
inline int read() {
	int x = 0;
	char ch = getchar();
	while(ch < '0' || ch > '9') {
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return x;
} 
void write(int x) {
	if(x > 9) {
		write(x / 10);
	}
	putchar(x % 10 + '0');
}
int T, n, m;
int a[100010], in[100010], out[100010], ans[100010];
vector<int> f[100010], e[100010];
queue<int> q;
void solve() {
	for(int i = 1; i <= n; ++i) {
		if(f[i].size() <= 1) continue;
		int x = f[i][f[i].size() - 1], y;
		for(int j = 0; j < f[i].size() - 1; ++j) {
			y = f[i][j];
			e[y].push_back(x);
			in[x] += 1;
			out[y] += 1;
			//cout << y << "F" << x << endl;
		}
		
	}
	
	int cnt = 0, op = 0;
	
	for(int i = m; i >= 2; --i) {
		if(in[i] == 0 && out[i] == 0) {
			ans[++cnt] = i;
			continue;
		}
		if(in[i] == 0) q.push(i);
	}
	if(in[1] == 0 && out[1] == 0) op = 1;
	else if(in[1] == 0) q.push(1);
	while(!q.empty()) {
		int x = q.front();
		q.pop();
		ans[++cnt] = x;
		for(int i = 0; i < e[x].size(); ++i) {
			int y = e[x][i];
			in[y] -= 1;
			if(in[y] == 0) q.push(y);
		}
	}
	if(op == 1) ans[++cnt] = 1;
	//for(int i = 1; i <= cnt; ++i) cout << ans[i] << " ";
	//cout << endl;
	if(cnt < m) {
		puts("No");
		return;
	} 
	for(int i = 1; i <= m; ++i) {
		if(ans[i] != i) break;
		if(i == m) {
			puts("No");
			return;
		}
	}
	puts("Yes");
	for(int i = 1; i < m; ++i) {
		write(ans[i]);putchar(' ');
	}
	write(ans[cnt]);
	putchar('\n');
}
int main() {
	T = read();
	while(T) {
		T -= 1;
		m = read();
		n = read();
		int num, x;
		for(int i = 1; i <= max(n,m); ++i) {
			a[i] = 0;
			in[i] = 0;
			out[i] = 0;
			ans[i] = 0;
			f[i].clear();
		} 
		for(int i = 1; i <= m; ++i) {
			num = read();
			for(int j = 1; j <= num; ++j) {
				x = read();
				f[x].push_back(i);
				a[x] = i;
			}
		}
		solve();
	}
	
	
	
}

详细

answer.code:1:1: error: ‘jr_zlw’ does not name a type
    1 | jr_zlw:
      | ^~~~~~
In file included from /usr/include/c++/13/bits/stl_algobase.h:62,
                 from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:15:
/usr/include/c++/13/ext/type_traits.h:164:35: error: ‘constexpr const bool __gnu_cxx::__is_null_pointer’ redeclared as different kind of entity
  164 |   __is_null_pointer(std::nullptr_t)
      |                                   ^
/usr/include/c++/13/ext/type_traits.h:159:5: note: previous declaration ‘template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)’
  159 |     __is_null_pointer(_Type)
      |     ^~~~~~~~~~~~~~~~~
/usr/include/c++/13/ext/type_traits.h:164:26: error: ‘nullptr_t’ is not a member of ‘std’; did you mean ‘nullptr_t’?
  164 |   __is_null_pointer(std::nullptr_t)
      |                          ^~~~~~~~~
In file included from /usr/include/c++/13/cstddef:50,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:41:
/usr/lib/gcc/x86_64-linux-gnu/13/include/stddef.h:443:29: note: ‘nullptr_t’ declared here
  443 |   typedef decltype(nullptr) nullptr_t;
      |                             ^~~~~~~~~
In file included from /usr/include/c++/13/bits/stl_pair.h:60,
                 from /usr/include/c++/13/bits/stl_algobase.h:64:
/usr/include/c++/13/type_traits:510:26: error: ‘std::size_t’ has not been declared
  510 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/13/type_traits:511:25: error: ‘_Size’ was not declared in this scope
  511 |     struct is_array<_Tp[_Size]>
      |                         ^~~~~
/usr/include/c++/13/type_traits:511:31: error: template argument 1 is invalid
  511 |     struct is_array<_Tp[_Size]>
      |                               ^
/usr/include/c++/13/type_traits:617:33: error: ‘nullptr_t’ is not a member of ‘std’; did you mean ‘nullptr_t’?
  617 |     struct is_null_pointer<std::nullptr_t>
      |                                 ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/include/stddef.h:443:29: note: ‘nullptr_t’ declared here
  443 |   typedef decltype(nullptr) nullptr_t;
      |                             ^~~~~~~~~
/usr/include/c++/13/type_traits:617:42: error: template argument 1 is invalid
  617 |     struct is_null_pointer<std::nullptr_t>
      |                                          ^
/usr/include/c++/13/type_traits:621:48: error: template argument 1 is invalid
  621 |     struct is_null_pointer<const std::nullptr_t>
      |                                                ^
/usr/include/c++/13/type_traits:625:51: error: template argument 1 is invalid
  625 |     struct is_null_pointer<volatile std::nullptr_t>
      |                                                   ^
/usr/include/c++/13/type_traits:629:57: error: template argument 1 is invalid
  629 |     struct is_null_pointer<const volatile std::nullptr_t>
      |                                                         ^
/usr/include/c++/13/type_traits:1348:37: error: ‘size_t’ is not a member of ‘std’; did you mean ‘size_t’?
 1348 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/include/stddef.h:214:23: note: ‘size_t’ declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/13/type_traits:1348:57: error: template argument 1 is invalid
 1348 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                                         ^
/usr/include/c++/13/type_traits:1348:57: note: invalid template non-type parameter
/usr/include/c++/13/type_traits:1357:37: error: ‘size_t’ is not a member of ‘std’; did you mean ‘size_t’?
 1357 |     : public integral_constant<std::size_t, 0> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/include/stddef.h:214:23: note: ‘size_t’ declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/13/type_traits:1357:46: error: template argument 1 is invalid
 1357 |     : public integral_constant<std::size_t, 0> { };
      |                                              ^
/usr/include/c++/13/type_traits:1357:46: note: invalid template non-type parameter
/usr/include/c++/13/type_traits:1359:26: error: ‘std::size_t’ has not been declared
 1359 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/13/type_traits:1360:21: error: ‘_Size’ was not declared in this scope
 1360 |     struct rank<_Tp[_Size]>
      |                     ^~~~~
/usr/include/c++/13/type_traits:1360:27: error: template argument 1 is invalid
 1360 |     struct rank<_Tp[_Size]>
      |                           ^
/usr/include/c++/13/type_traits:1361:37: error: ‘size_t’ is not a member of ‘std’; did you mean ‘size...