Submission #803896

# Submission time Handle Problem Language Result Execution time Memory
803896 2023-08-03T06:27:50 Z 박영우(#10104) Vera and Modern Art (CCO17_art) C++17
5 / 25
4000 ms 19036 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 110
#define MAXS 20
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
#define MOD 1000000007
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int N, Q;
	cin >> N >> Q;
	int i;
	ll a, b, c;
	map<pll, ll> mp;
	for (i = 1; i <= N; i++) {
		cin >> a >> b >> c;
		mp[pll(a, b)] += c;
	}
	vector<pair<pll, ll>> v;
	for (auto& [a, b] : mp) v.emplace_back(a, b);
	while (Q--) {
		cin >> a >> b;
		int i, j;
		ll sum = 0;
		for (i = 0; i <= 62; i++) {
			if (a < (1ll << i)) continue;
			for (j = 0; j <= 62; j++) {
				if (b < (1ll << j)) continue;
				ll mi, mj;
				mi = 1ll << i;
				mj = 1ll << j;
				mi--;
				mj--;
				ll x, y;
				x = a & mi;
				y = b & mj;
				x += mi + 1;
				y += mj + 1;
				int ind = lower_bound(v.begin(), v.end(), pair<pll, ll>(pll(x, y), 0)) - v.begin();
				if (ind < v.size() && v[ind].first == pll(x, y)) sum += v[ind].second;
			}
		}
		cout << sum << Ln;
	}
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:45:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<long long int, long long int>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     if (ind < v.size() && v[ind].first == pll(x, y)) sum += v[ind].second;
      |         ~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 139 ms 528 KB Output is correct
3 Correct 146 ms 524 KB Output is correct
4 Correct 143 ms 544 KB Output is correct
5 Correct 143 ms 524 KB Output is correct
6 Correct 48 ms 524 KB Output is correct
7 Correct 46 ms 468 KB Output is correct
8 Correct 46 ms 540 KB Output is correct
9 Correct 46 ms 540 KB Output is correct
10 Correct 45 ms 528 KB Output is correct
11 Correct 46 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4069 ms 19036 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2609 ms 9792 KB Output is correct
3 Correct 2470 ms 9800 KB Output is correct
4 Execution timed out 4059 ms 9572 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 139 ms 528 KB Output is correct
3 Correct 146 ms 524 KB Output is correct
4 Correct 143 ms 544 KB Output is correct
5 Correct 143 ms 524 KB Output is correct
6 Correct 48 ms 524 KB Output is correct
7 Correct 46 ms 468 KB Output is correct
8 Correct 46 ms 540 KB Output is correct
9 Correct 46 ms 540 KB Output is correct
10 Correct 45 ms 528 KB Output is correct
11 Correct 46 ms 544 KB Output is correct
12 Execution timed out 4069 ms 19036 KB Time limit exceeded
13 Halted 0 ms 0 KB -