답안 #411131

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
411131 2021-05-24T12:12:01 Z blacktulip The Collection Game (BOI21_swaps) C++17
컴파일 오류
0 ms 0 KB
#include "swaps.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>

using namespace std;

typedef long long lo; 
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 505;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;
int cmp[li][li],vis[li],viss[li][li];

void solve(int n, int V) {
	vector<int> v;
	int sayac=0;
	while(1){
		sayac++;
		if(sayac>V)break;
		FOR vis[i]=0;
		vector<pair<int,int>> vv;
		int flagg=0;
		for(int i=1;i<=n;i++){
			//~ cout<<"**\n";
			if(vis[i])continue;
			for(int x=n;x>=1;x--){
				j=rand()%n+1;
				while(vis[j] || i==j || viss[i][j] || viss[j][i]){
					j=rand()%n+1;
				}
				if(vis[j])continue;
				if(i==j)continue;
				if(viss[i][j] || viss[j][i])continue;
				viss[i][j]=1;
				vis[i]=1;
				vis[j]=1;
				schedule(i,j);
				flagg=1;
				vv.pb({i,j});
				break;
				//~ printf("%d %d %d\n",i,j,sayac);
			}
		}
		if(flagg==0)break;
		v=visit();
		int say=0;
		for(auto go:vv){
			if(v[say]==0){
				cmp[go.se][go.fi]=1;
			}
			else{
				cmp[go.fi][go.se]=1;
			}
			say++;
		}
	}
	vector<int> vec;
	vector<pair<int,int>> vv;
	for(int i=1;i<=n;i++){
		cev=0;
		for(int j=1;j<=n;j++){
			cev+=cmp[i][j];
		}
		vv.pb({cev,i});
	}
	sort(vv.begin(),vv.end());
	reverse(vv.begin(),vv.end());
	for(auto go:vv)vec.pb(go.se);
	answer(vec);
}

Compilation message

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:46:5: error: 'j' was not declared in this scope
   46 |     j=rand()%n+1;
      |     ^
swaps.cpp:58:16: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   58 |     vv.pb({i,j});
      |                ^
In file included from /usr/include/c++/10/vector:67,
                 from swaps.h:5,
                 from swaps.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~