답안 #644690

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
644690 2022-09-25T06:23:09 Z ymm 운세 보기 2 (JOI14_fortune_telling2) C++17
35 / 100
3000 ms 4212 KB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

const int N = 200'032;
const int S0 = 32767;
const int S1 = 2048;
int a[N], b[N];
unsigned short sa[N], sb[N];
int q[N];
unsigned short sq[N];
int n;

__attribute__((optimize("O3,unroll-loops"),target("avx2")))
void up(unsigned short x, unsigned short y, unsigned short z, int l, int r)
{
	Loop (i,l,r) {
		unsigned short v = sa[i], u = sb[i];
		v ^= v <= x? u: 0;
		v ^= v <= y? u: 0;
		v ^= v <= z? u: 0;
		sa[i] = v;
	}
}

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	int k;
	cin >> n >> k;
	Loop (i,0,n)
		cin >> a[i] >> b[i];
	Loop (i,0,k)
		cin >> q[i];
	ll ans = 0;
	for (int l0 = 0; l0 < n; l0 += S0) {
		int r0 = min(n, l0+S0);
		vector<int> vec = {0};
		Loop (i,l0,r0) {
			vec.push_back(a[i]);
			vec.push_back(b[i]);
		}
		sort(vec.begin(), vec.end());
		vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
		Loop (i,l0,r0) {
			sa[i] = lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin();
			sb[i] = lower_bound(vec.begin(), vec.end(), b[i]) - vec.begin();
			sb[i] ^= sa[i];
		}
		Loop (i,0,k)
			sq[i] = upper_bound(vec.begin(), vec.end(), q[i]) - vec.begin() - 1;
		for (int l1 = l0; l1 < r0; l1 += S1) {
			int r1 = min(r0, l1+S1);
			for (int i = 0; i < k; i += 3)
				up(sq[i+0], sq[i+1], sq[i+2], l1, r1);
		}
		Loop (i,l0,r0)
			ans += vec[sa[i]];
	}
	cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 15 ms 724 KB Output is correct
15 Correct 46 ms 952 KB Output is correct
16 Correct 86 ms 1220 KB Output is correct
17 Correct 160 ms 1372 KB Output is correct
18 Correct 181 ms 1332 KB Output is correct
19 Correct 157 ms 1360 KB Output is correct
20 Correct 154 ms 1384 KB Output is correct
21 Correct 158 ms 1340 KB Output is correct
22 Correct 141 ms 1328 KB Output is correct
23 Correct 141 ms 1380 KB Output is correct
24 Correct 149 ms 1368 KB Output is correct
25 Correct 140 ms 1344 KB Output is correct
26 Correct 117 ms 1304 KB Output is correct
27 Correct 165 ms 1368 KB Output is correct
28 Correct 143 ms 1412 KB Output is correct
29 Correct 146 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 15 ms 724 KB Output is correct
15 Correct 46 ms 952 KB Output is correct
16 Correct 86 ms 1220 KB Output is correct
17 Correct 160 ms 1372 KB Output is correct
18 Correct 181 ms 1332 KB Output is correct
19 Correct 157 ms 1360 KB Output is correct
20 Correct 154 ms 1384 KB Output is correct
21 Correct 158 ms 1340 KB Output is correct
22 Correct 141 ms 1328 KB Output is correct
23 Correct 141 ms 1380 KB Output is correct
24 Correct 149 ms 1368 KB Output is correct
25 Correct 140 ms 1344 KB Output is correct
26 Correct 117 ms 1304 KB Output is correct
27 Correct 165 ms 1368 KB Output is correct
28 Correct 143 ms 1412 KB Output is correct
29 Correct 146 ms 1372 KB Output is correct
30 Correct 186 ms 1868 KB Output is correct
31 Correct 826 ms 2476 KB Output is correct
32 Correct 1651 ms 3176 KB Output is correct
33 Execution timed out 3082 ms 4212 KB Time limit exceeded
34 Halted 0 ms 0 KB -