結果

問題 No.2184 A○B問題
ユーザー zezerozezero
提出日時 2023-01-13 21:48:04
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 611 bytes
コンパイル時間 399 ms
コンパイル使用メモリ 64,244 KB
最終ジャッジ日時 2023-08-26 03:30:35
合計ジャッジ時間 738 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:8:9: エラー: ‘vector’ was not declared in this scope
    8 |         vector<int> a(5);
      |         ^~~~~~
main.cpp:5:1: 備考: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
    4 | #include <numeric>
  +++ |+#include <vector>
    5 | using namespace std;
main.cpp:8:16: エラー: expected primary-expression before ‘int’
    8 |         vector<int> a(5);
      |                ^~~
main.cpp:9:16: エラー: expected primary-expression before ‘int’
    9 |         vector<int> b(5);
      |                ^~~
main.cpp:10:23: エラー: expected primary-expression before ‘int’
   10 |         vector<vector<int>> p(2,vector<int>(5));
      |                       ^~~
main.cpp:13:32: エラー: ‘p’ was not declared in this scope
   13 |                         cin >> p[i][j];
      |                                ^
main.cpp:16:14: エラー: ‘a’ was not declared in this scope
   16 |         iota(a.begin(),a.end(),0);
      |              ^
main.cpp:19:25: エラー: ‘b’ was not declared in this scope
   19 |                         b[p[1-i][j]-1] = a[j];
      |                         ^
main.cpp:19:27: エラー: ‘p’ was not declared in this scope
   19 |                         b[p[1-i][j]-1] = a[j];
      |                           ^
main.cpp:21:24: エラー: ‘b’ was not declared in this scope
   21 |                 swap(a,b);
      |                        ^
main.cpp:23:16: エラー: expected primary-expression before ‘int’
   23 |         vector<int> ans(5);
      |                ^~~
main.cpp:25:17: エラー: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   25 |                 ans[a[i]] = i+1;
      |                 ^~~
      |                 abs
main.cpp:28:37: エラー: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   28 |                 if (i == 0) cout << ans[i];
   

ソースコード

diff #

#include<iostream>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;
int main(){
	int n;
	vector<int> a(5);
	vector<int> b(5);
	vector<vector<int>> p(2,vector<int>(5));
	for (int i = 0; i < 2;i++){
		for (int j = 0; j < 5;j++){
			cin >> p[i][j];
		}
	}
	iota(a.begin(),a.end(),0);
	for (int i = 0; i < 2;i++){
		for (int j = 0; j < 5;j++){
			b[p[1-i][j]-1] = a[j];
		}
		swap(a,b);
	}
	vector<int> ans(5);
	for (int i = 0; i < 5;i++){
		ans[a[i]] = i+1;
	}
	for (int i = 0; i < 5;i++){
		if (i == 0) cout << ans[i];
		else cout << " " << ans[i];
	}
	cout << endl;
	
	return 0;
}

0