Submission #698959

# Submission time Handle Problem Language Result Execution time Memory
698959 2023-02-15T02:46:56 Z josanneo22 Duathlon (APIO18_duathlon) C++17
0 / 100
1000 ms 1492 KB
#include<bits/stdc++.h>
#include<iostream>
#include<stdlib.h>
#include<cmath>
#include <algorithm>
#include<numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<ll> vll;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define trav(a,x) for (auto& a: x)
#define fr(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>=(b); i+=(s))
#define fr1(e) fr(i, 0, e, 1)
#define fr2(i, e) fr(i, 0, e, 1)
#define fr3(i, b, e) fr(i, b, e, 1)
#define mp make_pair
#define pb push_back
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define in insert
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define out(x) cout<<x<<'\n'
int dx[4] = { -1, 0, 1, 0 };
int dy[4] = { 0, 1, 0, -1 };

double pi = 3.141592;
ll mod = 1e9 + 7;

void xd(string str)
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	if (str != "")
	{
		//freopen((str + ".in").c_str(), "r", stdin);
		//freopen((str + ".out").c_str(), "w", stdout);
	}
}
int add(int a, int b, int mod) { return (((a % mod) + (b % mod)) + mod) % mod; }
int sub(int a, int b, int mod) { return (((a % mod) - (b % mod)) + mod) % mod; }
int mul(int a, int b, int mod) { return (((a % mod) * (b % mod)) + mod) % mod; }
int bin(int a, int b, int mod) { int ans = 1; while (b) { if (b & 1) ans = mul(ans, a, mod); a = mul(a, a, mod); b >>= 1; }return ans; }
int inverse(int a, int mod) { return bin(a, mod - 2, mod); }
int divi(int a, int b, int mod) {
	return mul(a, inverse(b, mod), mod);
}
ll add(ll a, ll b, ll mod) { return (((a % mod) + (b % mod)) + mod) % mod; }
ll sub(ll a, ll b, ll mod) { return (((a % mod) - (b % mod)) + mod) % mod; }
ll mul(ll a, ll b, ll mod) { return (((a % mod) * (b % mod)) + mod) % mod; }
ll bin(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1) ans = mul(ans, a, mod); a = mul(a, a, mod); b >>= 1; }return ans; }
ll inverse(ll a, ll mod) { return bin(a, mod - 2, mod); }
ll divi(ll a, ll b, ll mod) {
	return mul(a, inverse(b, mod), mod);
}
ll ex(int base, int power)
{
	if (power == 0)
		return 1;
	ll result = ex(base, power / 2);
	if (power % 2 == 1)
		return(((result * result) % mod) * base) % mod;
	else return (result * result) % mod;
}
int gcd(int a, int b) {
	if (b == 0)return a;
	else return gcd(b, a % b);
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
ll fac(int x) {
	ll factorial = 1;
	for (ll i = 1; i <= x; ++i) {
		factorial = mul(factorial, i, mod);
	}
	return factorial % mod;
}
ll npr(int x, int c) {
	if (x < c) return 0;
	if (x == c) return fac(x);
	else return (fac(x) / (fac(x - c)));
}
ll ncr(int x, int c) {
	if (x < c) return 0;
	if (x == c) return 1;
	else return (fac(x) / ((fac(x - c) * fac(c))));
}
void bton(string s) { stoll(s, nullptr, 2); }
inline int read() {
	int x = 0, f = 1, c = getchar();
	while (!isdigit(c)) { if (c == '-')f = -1; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	return f == 1 ? x : -x;
}
bool isPrime(int n)
{
	if (n == 2 || n == 3)
		return true;

	if (n <= 1 || n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6) {
		if (n % i == 0 || n % (i + 2) == 0)
			return false;
	}

	return true;
}
int ceil_int(int first_number, int divider) {
	if (first_number % divider == 0) return first_number / divider;
	else return first_number / divider + 1;
}
ll ceil_ll(ll first_number, ll divider) {
	if (first_number % divider == 0) return first_number / divider;
	else return first_number / divider + 1LL;
}

vector<int> smallest_factor;
vector<bool> prime;
vector<int> primes;

// Note: this sieve is O(n), but the constant factor is worse than the O(n log log n) sieve due to the multiplication.
void sieve(int maximum) {
	maximum = max(maximum, 1);
	smallest_factor.assign(maximum + 1, 0);
	prime.assign(maximum + 1, true);
	prime[0] = prime[1] = false;
	primes = {};

	for (int i = 2; i <= maximum; i++) {
		if (prime[i]) {
			smallest_factor[i] = i;
			primes.push_back(i);
		}

		for (int p : primes) {
			if (p > smallest_factor[i] || int64_t(i) * p > maximum)
				break;
			prime[i * p] = false;
			smallest_factor[i * p] = p;
		}
	}
}
int computeXOR(int n)
{
	if (n % 4 == 0)
		return n;
	if (n % 4 == 1)
		return 1;
	if (n % 4 == 2)
		return n + 1;
	return 0;
}

int digit_sum(int g) {
	int cnt = 0;
	while (g > 0) {
		cnt += g % 10;
		g /= 10;
	}
	return cnt;
}
const int maxn = 102;
vi adj[maxn];
vi vis[maxn];
void solve()
{
	int n, k; cin >> n >> k;
	FOR(i, 0, k) {
		int u, v; cin >> u >> v;
	}
	ll ans = 0;
	FOR(i, 0, n) {
		ans += ncr(i, 2)+ ncr(n - i-1, 2);
	}
	cout << ans << '\n';
}
int main()
{
	xd("");
	int t = 1;// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 1408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 1492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 1412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -