QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#831140#8903. Тайное посланиеWanyeCompile Error//C++141000b2024-12-25 11:10:012024-12-25 11:10:30

Judging History

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

  • [2024-12-25 11:10:30]
  • 评测
  • [2024-12-25 11:10:01]
  • 提交

answer

std::vector<int> Encode(int n, int k, std::vector<int> T){
	vector<int> vis(n);
	stack<int> sta;
	while(sta.size()) sta.pop();
	for(int i=0;i<n;i++) vis[i]=0;
	for(int i=0;i<k;i++) vis[T[i]-1]=1;
	for(int i=0;i<n;i++){
		if(vis[i]==1) sta.push(i);
		else if(sta.size()){
			sta.pop();
			vis[i]=2;
		}
	}
	for(int i=0;i<n;i++){
		if(sta.size()&&!vis[i]){
			vis[i]=2;
			sta.pop();
		}
	}
	vector<int> R(0);
	for(int i=0;i<n;i++) if(vis[i]==2) R.push_back(i+1);
	return R;
}
std::vector<int> Decode(int n, int k, std::vector<int> R){
	vector<int> vis(n);
	stack<int> sta;
	while(sta.size()) sta.pop();
	for(int i=0;i<n;i++) vis[i]=0;
	for(int i=0;i<k;i++) vis[R[i]-1]=1;
	for(int i=n-1;i>=0;i--){
		if(vis[i]==1) sta.push(i);
		else if(sta.size()){
			sta.pop();
			vis[i]=2;
		}
	}
	for(int i=n-1;i>=0;i--){
		if(sta.size()&&!vis[i]){
			vis[i]=2;
			sta.pop();
		}
	}
	vector<int> T(0);
	for(int i=0;i<n;i++) if(vis[i]==2) T.push_back(i+1);
	return T;
}

詳細信息

answer.code:1:6: error: ‘vector’ in namespace ‘std’ does not name a template type
    1 | std::vector<int> Encode(int n, int k, std::vector<int> T){
      |      ^~~~~~
answer.code:1:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
  +++ |+#include <vector>
    1 | std::vector<int> Encode(int n, int k, std::vector<int> T){
answer.code:24:6: error: ‘vector’ in namespace ‘std’ does not name a template type
   24 | std::vector<int> Decode(int n, int k, std::vector<int> R){
      |      ^~~~~~
answer.code:24:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
   24 | std::vector<int> Decode(int n, int k, std::vector<int> R){
      | ^~~