답안 #468850

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
468850 2021-08-29T20:46:23 Z mychecksedad Xor Sort (eJOI20_xorsort) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
	cin.tie(0); ios::sync_with_stdio(0);
	int n, s, arr[1010];
	cin >> n >> s;
	for(int i = 1; i <= n; i++) cin >> arr[i];
	vector<pair<int, int>> ans;
	if(s == 1){

	}else{
		for(int bit = 20; bit >= 0; bit--){
			for(int i = 1; i < n; i++){
				if((1<<bit)&arr[i]){
					if((1<<bit)&(arr[i + 1])){
						ans.pb({i+1, i});
						ans.pb({i, i+1});
						arr[i + 1] ^= (1<<bit);
						arr[i] ^= (1<<bit);
					}else{
						ans.pb({i, i+1});
						arr[i] ^= (1<<bit);
					}
				}
			}
		}
	}
	cout << ans.size() << '\n';
	for(auto k: ans) cout << k.first << ' ' << k.second << '\n';


	return 0;
}

Compilation message

xorsort.cpp: In function 'int main()':
xorsort.cpp:17:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'pb'
   17 |       ans.pb({i+1, i});
      |           ^~
xorsort.cpp:18:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'pb'
   18 |       ans.pb({i, i+1});
      |           ^~
xorsort.cpp:22:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'pb'
   22 |       ans.pb({i, i+1});
      |           ^~