Submission #476580

# Submission time Handle Problem Language Result Execution time Memory
476580 2021-09-27T17:22:34 Z vbee Hexagonal Territory (APIO21_hexagon) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>
#define fi first
#define se second
#define TASK "hexagon"
#define ll long long
#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define pb push_back
#define MASK(i) (1 << (i))
#define BIT(x, i) ((x >> (i)) & 1)
 
using namespace std;

const int oo = 1e9 + 7;
const ll loo = (ll)1e18 + 7; 
const int N = 200007;
int n, curx, cury;
vll row[N];
void solve(int x, int l){
	for (int i = 1; i <= l; i++){
		if (x == 1){
			curx--;
			cury++;
		}
		else if (x == 2){
			cury++;
		} 
		else if (x == 3){
			curx++; 
		}
		else if (x == 4){
			curx++;
			cury--;
		}
		else if (x == 5){
			cury--;
		}
		else if (x == 6){
			curx--;
		}
		row[curx].pb(cury);
	}
}
void sub1(){
	ll l[4];
	for (int i = 1; i <= n; i++){
		ll x; cin >> x >> l[i];
	}
	if (l[2] == l[1]){
		cout << ((l[1] + 2) * (l[1] + 1) / 2) % oo;
	} else if (l[2] == 2 * l[1]){
		cout << 1LL * (l[1] + 1) * (l[1] + 1) % oo;
	}
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	// freopen(TASK".inp", "r", stdin);
	// freopen(TASK".out", "w", stdout);
	cin >> n;
	if (n == 3){
		sub1();
		return 0;
	}
	curx = 10000, cury = 10000;
	row[10000].pb(cury);
	for (int i = 1; i <= n; i++){
		int x, l; cin >> x >> l;
		solve(x, l);
	}	
	ll res = 0;
	for (int i = 0; i < N; i++) if (row[i].size()){
		sort(all(row[i]));
		res = (res + row[i].back() - *row[i].begin() + 1) % oo;;
	}
	cout << res;
	return 0;
}

Compilation message

/usr/bin/ld: /tmp/cchlPPhl.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cciyfs4m.o:hexagon.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cchlPPhl.o: in function `main':
grader.cpp:(.text.startup+0x220): undefined reference to `draw_territory(int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status