Submission #987603

#TimeUsernameProblemLanguageResultExecution timeMemory
987603happypotatoGame (IOI13_game)C++17
Compilation error
0 ms0 KiB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
ll gcd[2001][2001];
ll gcd(ll a, ll b) {
	if (a <= 2000 && b <= 2000) return sto[a][b];
	while (b) b ^= a ^= b ^= a %= b;
	return a;
}
void init(int R, int C) {
	for (int i = 0; i <= 2000; i++) {
		for (int j = 0; j <= 2000; j++) {
			sto[i][j] = gcd(i, j);
		}
	}
}
vector<pair<pii, ll>> v;
void update(int P, int Q, long long K) {
	for (auto it = v.begin(); it != v.end(); ++it) {
		if (it->ff.ff == P && it->ff.ss == Q) {
			v.erase(it);
			break;
		}
	}
	v.pb({{P, Q}, K});
	// for (pair<pii, ll> &x : v) cerr << x.ff.ff << ' ' << x.ff.ss << ' ' << x.ss << endl;
	// cerr << endl;
}

long long calculate(int P, int Q, int U, int V) {
	if (P > U) swap(P, U);
	if (Q > V) swap(Q, V);
	ll res = 0;
	for (pair<pii, ll> &x : v) {
		if (P <= x.ff.ff && x.ff.ff <= U && Q <= x.ff.ss && x.ff.ss <= V) {
			res = gcd(res, x.ss);
			if (res == 1) break;
		}
	}
	return res;
}

Compilation message (stderr)

game.cpp:12:4: error: reference to 'gcd' is ambiguous
   12 | ll gcd(ll a, ll b) {
      |    ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:84,
                 from game.cpp:2:
/usr/include/c++/10/numeric:131:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  131 |     gcd(_Mn __m, _Nn __n)
      |     ^~~
game.cpp:11:4: note:                 'long long int gcd [2001][2001]'
   11 | ll gcd[2001][2001];
      |    ^~~
game.cpp:12:18: error: 'long long int gcd(long long int, long long int)' redeclared as different kind of entity
   12 | ll gcd(ll a, ll b) {
      |                  ^
game.cpp:11:4: note: previous declaration 'long long int gcd [2001][2001]'
   11 | ll gcd[2001][2001];
      |    ^~~
game.cpp: In function 'long long int gcd(long long int, long long int)':
game.cpp:13:37: error: 'sto' was not declared in this scope; did you mean 'std'?
   13 |  if (a <= 2000 && b <= 2000) return sto[a][b];
      |                                     ^~~
      |                                     std
game.cpp: In function 'void init(int, int)':
game.cpp:20:4: error: 'sto' was not declared in this scope; did you mean 'std'?
   20 |    sto[i][j] = gcd(i, j);
      |    ^~~
      |    std
game.cpp:20:16: error: reference to 'gcd' is ambiguous
   20 |    sto[i][j] = gcd(i, j);
      |                ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:84,
                 from game.cpp:2:
/usr/include/c++/10/numeric:131:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  131 |     gcd(_Mn __m, _Nn __n)
      |     ^~~
game.cpp:11:4: note:                 'long long int gcd [2001][2001]'
   11 | ll gcd[2001][2001];
      |    ^~~
game.cpp: In function 'long long int calculate(int, int, int, int)':
game.cpp:43:10: error: reference to 'gcd' is ambiguous
   43 |    res = gcd(res, x.ss);
      |          ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:84,
                 from game.cpp:2:
/usr/include/c++/10/numeric:131:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  131 |     gcd(_Mn __m, _Nn __n)
      |     ^~~
game.cpp:11:4: note:                 'long long int gcd [2001][2001]'
   11 | ll gcd[2001][2001];
      |    ^~~