Submission #965712

#TimeUsernameProblemLanguageResultExecution timeMemory
965712pccSwapping Cities (APIO20_swap)C++17
Compilation error
0 ms0 KiB
#include "swap.h"

#include <vector>
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fs first
#define sc second
const int mxn = 1e5+10;

int ans = 0;
vector<pii> v;
int arr[mxn];
int N,M;

void init(int NN, int MM,
          std::vector<int> U, std::vector<int> V, std::vector<int> W) {
	N = NN,M = MM;
	for(int i = 0;i<M;i++){
		arr[V[i]] = W[i];
		v.push_back(pii(W[i],V[i]));
	}
	sort(v.begin(),v.end());
	return;

}

int getMinimumFuelCapacity(int X, int Y) {
	if(N<=2)return -1;
	if(!X){
		if(Y == v[0].sc)return v[1].fs;
		else return arr[Y];
	}
	if(N<=3)return -1;
	if(arr[X]>arr[Y])swap(X,Y);
	if(X == arr[0].sc&&Y == arr[1].sc)return arr[2].fs;
	else return arr[Y];
}

Compilation message (stderr)

swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:9:12: error: request for member 'second' in 'arr[0]', which is of non-class type 'int'
    9 | #define sc second
      |            ^~~~~~
swap.cpp:37:17: note: in expansion of macro 'sc'
   37 |  if(X == arr[0].sc&&Y == arr[1].sc)return arr[2].fs;
      |                 ^~
swap.cpp:9:12: error: request for member 'second' in 'arr[1]', which is of non-class type 'int'
    9 | #define sc second
      |            ^~~~~~
swap.cpp:37:33: note: in expansion of macro 'sc'
   37 |  if(X == arr[0].sc&&Y == arr[1].sc)return arr[2].fs;
      |                                 ^~
swap.cpp:8:12: error: request for member 'first' in 'arr[2]', which is of non-class type 'int'
    8 | #define fs first
      |            ^~~~~
swap.cpp:37:50: note: in expansion of macro 'fs'
   37 |  if(X == arr[0].sc&&Y == arr[1].sc)return arr[2].fs;
      |                                                  ^~