This commit is contained in:
2026-06-26 18:42:29 +09:00
parent bc1489d320
commit 5a14bd0d2d
5 changed files with 309 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
#include <iostream>
#include <algorithm>
#include <vector>
#define let auto
#define fn auto
#define usize size_t
using namespace std;
const usize MOD = 1'000'000'007;
fn fastio() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
/**
*
* If there is energy x phage
* f(1, x) = f(2, x + 1) + f(2, x - 1)
* 0 0 0 1 0 0 0 0 0
* 0 0 1 0 1 2
* 0 1 0 2 0 0 0 0
* 1 0 3 0 3 0 0 0 8
* 0 4 0
* 4 0 10 0 10
* 0 14 0 20
* 14 0 34 35 119
* 48 68
*/
/**
* 1
* 1 1
* 1 2 1
* 1 3 3 1
* 1 4 6 4 1
* 1 5 10 10 5 1
* 1 6 15 20 15 6 1
* 1 7 21 35 35
*
* 48
*
*
*
* 1 4 10+4 14+14+20 14+20+
*/
// 10 4일 때
// 1 2 4 8 15 30
// 0 1 2 3 4 5 6 7 8 9
fn main() -> int {
fastio();
usize k, n;
usize col1 = 0;
usize col2 = 0;
cin >> k >> n;
}

View File

@@ -0,0 +1,52 @@
#include <iostream>
#include <algorithm>
#include <vector>
#define let auto
#define fn auto
#define usize size_t
using namespace std;
const usize MOD = 1'000'000'007;
fn fastio() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
/**
*
*/
fn main() -> int {
usize t;
usize n;
usize k;
usize ret;
cout << (1 ^ 2) << endl;
return 0;
cin >> t;
/**
*
* xor0이 가능한 클러스터 X1, X2에 대해서
* X1과 X2를 연결한 클러스터 X1-X2도 동일한 속성을 만족하는 클러스터임.
* xor0이 가능한 최소 클러스터 크기는 1임
* 1
* { 1 2 3 }이 가능한클러스터군... 죽고 싶다
* { 0, 0 } {1, 1}, {2, 2} (자유도 만큼) k + 1
* {0, 0, 0}, {0, 1, 1}, {1, 0, 1}, {1, 1, 0}, {0, 2, 2}, {1, 1, 0}, 3 * k + 1
* { 0011 } {0022} {0033} {1122} {1133} {2233} {0000}{1111}{2222}{3333}
*/
while (t--) {
cin >> n >> k;
if (k == 0) {
ret = 1;
} else {
}
cout << ret << "\n";
}
}

View File

@@ -0,0 +1,95 @@
#include <algorithm>
#include <iostream>
#include <vector>
#define let auto
#define fn auto
#define usize size_t
using namespace std;
struct Node {
usize acc;
usize self;
vector<Node *> *adjs;
void add_route(Node *node) {
adjs->push_back(node);
}
void update_delta(usize delta) {
acc += delta;
self += delta;
for (let x: *adjs) {
x->update_by_direct(delta);
}
}
void update_by_direct(usize delta) {
acc += delta;
}
};
fn fastio() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
fn main() -> int {
fastio();
usize n, q;
cin >> n >> q;
let arr = (usize *) calloc(n, sizeof(usize));
let graph = (Node **) calloc(n, sizeof(Node *));
for (usize i = 0; i < n; i++) {
graph[i] = (Node *) malloc(sizeof(Node));
graph[i]->acc = 0;
graph[i]->self = 0;
graph[i]->adjs = new vector<Node *>();
}
for (usize i = 0; i < n; i++) {
usize a;
cin >> a;
arr[i] = a;
}
for (usize i = 0; i < n - 1; i++) {
usize u, v;
cin >> u >> v;
u = u - 1;
v = v - 1;
graph[u]->add_route(graph[v]);
graph[v]->add_route(graph[u]);
}
for (usize i = 0; i < n; i++) {
graph[i]->update_delta(arr[i]);
}
for (usize i = 0; i < q; i++) {
usize inst;
cin >> inst;
if (inst == 1) {
usize target, c;
cin >> target >> c;
target -= 1;
graph[target]->update_delta(c);
} else {
usize target;
cin >> target;
target -= 1;
cout << graph[target]->acc << '\n';
}
}
end:
free(arr);
for (usize i = 0; i < n; i++) {
delete graph[i]->adjs;
free(graph[i]);
}
free(graph);
}

View File

@@ -0,0 +1,72 @@
#include <algorithm>
#include <iostream>
#include <vector>
#define let auto
#define fn auto
#define usize size_t
using namespace std;
const usize MOD = 1'000'000'007;
fn fastio() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
fn count_ilove(usize x, const vector<usize> &hates) -> usize {
if (x == 0) return 0;
string s = to_string(x);
usize n = s.size();
vector<vector<vector<usize>>> dp(n + 1,
vector<vector<usize>>(2, vector<usize>(2, 0)));
dp[0][1][0] = 1;
for (usize pos = 0; pos < n; pos++) {
for (usize tight = 0; tight <= 1; tight++) {
for (usize started = 0; started <= 1; started++) {
usize limit = tight ? (s[pos] - '0') : 9;
for (usize digit = 0; digit <= limit; digit++) {
bool is_hated = false;
for (usize h: hates) {
if (h == digit) {
is_hated = true;
break;
}
}
if (is_hated) continue;
bool next_started = started || (digit != 0);
usize next_tight = (tight && digit == limit) ? 1 : 0;
if (!next_started && pos == n - 1) continue;
dp[pos + 1][next_tight][next_started] += dp[pos][tight][started];
}
}
}
}
usize result = 0;
for (usize tight = 0; tight <= 1; tight++) {
result += dp[n][tight][1];
}
return result;
}
fn main() -> int {
fastio();
usize n, l, r;
cin >> n >> l >> r;
vector<usize> hates(n);
for (usize i = 0; i < n; i++) {
cin >> hates[i];
}
usize ret = (count_ilove(r, hates) + 2 * MOD - (count_ilove(l - 1, hates))) % MOD;
cout << ret % MOD << "\n";
}

View File

@@ -0,0 +1,27 @@
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdint>
:
#define let auto
#define fn auto
#define usize size_t
#define u64 uint64_t
#define i64 int64_t
using namespace std;
fn fastio() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
fn main() -> int {
fastio();
u64 r, u, n;
cin >> r >> u >> n;
// f(n-2) f(n-1) f(n)
// f(n-2) * r + f(n-1) * u
// 일정 이상의 n에 대해서 f(n-2)와 f(n-1)은 서로소임.
}