QOJ.ac

QOJ

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

Judging History

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

  • [2024-12-25 11:11:08]
  • 评测
  • [2024-12-25 11:11:08]
  • 提交

answer

#include<vector>
#include<stack>

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: In function ‘std::vector<int> Encode(int, int, std::vector<int>)’:
answer.code:5:9: error: ‘vector’ was not declared in this scope; did you mean ‘std::vector’?
    5 |         vector<int> vis(n);
      |         ^~~~~~
      |         std::vector
In file included from /usr/include/c++/13/vector:66,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_vector.h:425:11: note: ‘std::vector’ declared here
  425 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
answer.code:5:16: error: expected primary-expression before ‘int’
    5 |         vector<int> vis(n);
      |                ^~~
answer.code:6:9: error: ‘stack’ was not declared in this scope; did you mean ‘std::stack’?
    6 |         stack<int> sta;
      |         ^~~~~
      |         std::stack
In file included from /usr/include/c++/13/stack:63,
                 from answer.code:2:
/usr/include/c++/13/bits/stl_stack.h:99:11: note: ‘std::stack’ declared here
   99 |     class stack
      |           ^~~~~
answer.code:6:15: error: expected primary-expression before ‘int’
    6 |         stack<int> sta;
      |               ^~~
answer.code:7:15: error: ‘sta’ was not declared in this scope; did you mean ‘std’?
    7 |         while(sta.size()) sta.pop();
      |               ^~~
      |               std
answer.code:8:30: error: ‘vis’ was not declared in this scope
    8 |         for(int i=0;i<n;i++) vis[i]=0;
      |                              ^~~
answer.code:9:30: error: ‘vis’ was not declared in this scope
    9 |         for(int i=0;i<k;i++) vis[T[i]-1]=1;
      |                              ^~~
answer.code:11:20: error: ‘vis’ was not declared in this scope
   11 |                 if(vis[i]==1) sta.push(i);
      |                    ^~~
answer.code:11:31: error: ‘sta’ was not declared in this scope; did you mean ‘std’?
   11 |                 if(vis[i]==1) sta.push(i);
      |                               ^~~
      |                               std
answer.code:12:25: error: ‘sta’ was not declared in this scope; did you mean ‘std’?
   12 |                 else if(sta.size()){
      |                         ^~~
      |                         std
answer.code:18:20: error: ‘sta’ was not declared in this scope; did you mean ‘std’?
   18 |                 if(sta.size()&&!vis[i]){
      |                    ^~~
      |                    std
answer.code:18:33: error: ‘vis’ was not declared in this scope
   18 |                 if(sta.size()&&!vis[i]){
      |                                 ^~~
answer.code:23:16: error: expected primary-expression before ‘int’
   23 |         vector<int> R(0);
      |                ^~~
answer.code:24:33: error: ‘vis’ was not declared in this scope
   24 |         for(int i=0;i<n;i++) if(vis[i]==2) R.push_back(i+1);
      |                                 ^~~
answer.code:24:44: error: ‘R’ was not declared in this scope
   24 |         for(int i=0;i<n;i++) if(vis[i]==2) R.push_back(i+1);
      |                                            ^
answer.code:25:16: error: ‘R’ was not declared in this scope
   25 |         return R;
      |                ^
answer.code: In function ‘std::vector<int> Decode(int, int, std::vector<int>)’:
answer.code:28:9: error: ‘vector’ was not declared in this scope; did you mean ‘std::vector’?
   28 |         vector<int> vis(n);
      |         ^~~~~~
      |         std::vector
/usr/include/c++/13/bits/stl_vector.h:425:11: note: ‘std::vector’ declared here
  425 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
answer.code:28:16: error: expected primary-expression before ‘int’
   28 |         vector<int> vis(n);
      |                ^~~
answer.code:29:9: error: ‘stack’ was not declared in this scope; did you mean ‘std::stack’?
   29 |         stack<int> sta;
      |         ^~~~~
      |         std::stack
/usr/include/c++/13/bits/stl_stack.h:99:11: note: ‘std::stack’ declared here
   99 |     class stack
      |           ^~~~~
answer.code:29:15: error: expected primary-expression before ‘int’
   29 |         stack<int> sta;
      |               ^~~
answer.code:30:15: error: ‘sta’ was not declared in this scope; did you mean ‘std’?
   30 |         while(sta.size()) sta.pop();
      |               ^~~
      |               std
answer.code:31:30: error: ‘vis’ was not declared in this scope
   31 |         for(int i=0;i<n;i++) vis[i]=0;
      |                              ^~~
answer.code:32:30: error: ‘vis’ was not declared in this scope
   32 |         for(int i=0;i<k;i++) vis[R[i]-1]=1;
      |                              ^~~
answer.code:34:20: error: ‘vis’ was not declared in this scope
   34 |                 if(vis[i]==1) sta.push(i);
      |                    ^~~
answer.code:34:31: error: ‘sta’ was not declared in this scope; did you mean ‘std’?
   34 |                 if(vis[i]==1) sta.push(i);
      |                               ^~~
      |                               std
answer.co...