## AtCoder ABC197

news/2024/2/24 7:35:04/文章来源:https://blog.csdn.net/acrux1985/article/details/135636443

### C - ORXOR

n=20，可以暴力

# -*- coding: utf-8 -*-
# @time     : 2023/6/2 13:30
# @file     : atcoder.py
# @software : PyCharmimport bisect
import copy
import sys
from itertools import permutations
from sortedcontainers import SortedList
from collections import defaultdict, Counter, deque
from functools import lru_cache, cmp_to_key
import heapq
import math
sys.setrecursionlimit(100010)def check(arr_list):ret = 0for arr in arr_list:temp = 0for x in arr:temp |= xret ^= tempreturn retdef main():items = sys.version.split()fp = open("in.txt") if items[0] == "3.10.6" else sys.stdinn = int(fp.readline())a = list(map(int, fp.readline().split()))ans = 1 << 60for mask in range(1 << n):b = []temp = []for i in range(n):temp.append(a[i])if (mask >> i) & 1:b.append(temp)temp = []if len(temp) > 0:b.append(temp)ans = min(ans, check(b))print(ans)if __name__ == "__main__":main()

### D - Opposite

[ x 1 y 1 ] = [ c o s θ − s i n θ s i n θ c o s θ ] [ x 0 y 0 ] \begin {bmatrix} x_1 \\ y_1 \end{bmatrix} = \begin {bmatrix} cos\theta &-sin\theta \\ sin\theta & cos\theta \end{bmatrix} \begin {bmatrix} x_0 \\ y_0 \end{bmatrix}

#define _CRT_SECURE_NO_WARNINGS#include <iostream>
#include <string>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <map>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <unordered_map>
#include <algorithm>
#define LT(x) (x * 2)
#define RT(x) (x * 2 + 1)using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
const ll inf = ll(1e15);
const ld pi = 3.1415926535897932384626;int n;int main() {//freopen("in.txt", "r", stdin);scanf("%d", &n);int x0, y0, xn, yn;scanf("%d%d%d%d", &x0, &y0, &xn, &yn);ld dx0, dy0, dxn, dyn;dx0 = x0, dy0 = y0, dxn = xn, dyn = yn;ld cx = (dx0 + dxn) / 2, cy = (dy0 + dyn) / 2;ld x = dx0 - cx, y = dy0 - cy;ld sinx = sin(2.0 * pi / n), cosx = cos(2.0 * pi / n);ld nx = x * cosx - y * sinx + cx, ny = x * sinx + y * cosx + cy;printf("%.8Lf %.8Lf\n", nx, ny);return 0;
}


### E - Traveler

#define _CRT_SECURE_NO_WARNINGS#include <iostream>
#include <string>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <map>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <unordered_map>
#include <algorithm>
#define LT(x) (x * 2)
#define RT(x) (x * 2 + 1)using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
const ll inf = ll(1e15);
const ld pi = 3.1415926535897932384626;int n;
vi balls[200020];
ll dp[200020][2];int main() {//freopen("in.txt", "r", stdin);scanf("%d", &n);for (int i = 0; i < n; ++i) {int x, c;scanf("%d%d", &x, &c);balls[c].push_back(x);}for (int i = 0; i <= n; ++i) {sort(balls[i].begin(), balls[i].end());}dp[0][0] = dp[0][1] = 0;balls[0] = { 0 };vi last = balls[0];for (int i = 1; i <= n; ++i) {if (balls[i].size() == 0) {dp[i][0] = dp[i - 1][0], dp[i][1] = dp[i - 1][1];}else {int m = balls[i].size(), lm = last.size();ll l0 = last[0], r0 = last[lm - 1], l1 = balls[i][0], r1 = balls[i][m - 1];dp[i][0] = min(abs(l0 - r1) + dp[i - 1][0], abs(r0 - r1) + dp[i - 1][1]) + r1 - l1;dp[i][1] = min(abs(l0 - l1) + dp[i - 1][0], abs(r0 - l1) + dp[i - 1][1]) + r1 - l1;last = balls[i];}}ll ans = min(abs(last[0]) + dp[n][0], abs(last[last.size() - 1]) + dp[n][1]);printf("%lld\n", ans);return 0;
}


### F - Construct a Palindrome

#define _CRT_SECURE_NO_WARNINGS#include <iostream>
#include <string>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <map>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <unordered_map>
#include <algorithm>
#define LT(x) (x * 2)
#define RT(x) (x * 2 + 1)using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
const ll inf = ll(1e15);
const ld pi = 3.1415926535897932384626;int n, m;
vi g[1002][26];
int f[1002][1002];
bool w[1002][1002];int main() {//freopen("in.txt", "r", stdin);cin >> n >> m;for (int i = 0; i < m; ++i) {int u, v;char c;cin >> u >> v >> c;int p = c - 'a';g[u][p].push_back(v);g[v][p].push_back(u);w[u][v] = w[v][u] = 1;}memset(f, 0xff, sizeof(f));f[1][n] = 0;int ans = 1 << 30;queue<pii> qu;qu.push({ 1, n });while (!qu.empty()) {pii c = qu.front();qu.pop();int u0 = c.first, u1 = c.second;if (u0 == u1) {if (f[u0][u1] * 2 <= ans - 1)ans = f[u0][u1] * 2;}if (w[u0][u1]) {ans = min(ans, f[u0][u1] * 2 + 1);}for (int p = 0; p < 26; ++p) {for (int v0 : g[u0][p]) {for (int v1 : g[u1][p]) {if (f[v0][v1] == -1) {f[v0][v1] = f[u0][u1] + 1;qu.push({ v0, v1 });}}}}}if (ans > 200000) ans = -1;printf("%d\n", ans);return 0;
}

### java基础知识点系列——数据输入（五）

java基础知识点系列——数据输入&#xff08;五&#xff09; 数据输入概述 Scanner使用步骤 &#xff08;1&#xff09;导包 import java.util.Scanner&#xff08;2&#xff09;创建对象 Scanner sc new Scanner(System.in)&#xff08;3&#xff09;接收数据 int i sc…

### TRB 2024论文分享：基于生成对抗网络和Transformer模型的交通事件检测混合模型

TRB&#xff08;Transportation Research Board&#xff0c;美国交通研究委员会&#xff0c;简称TRB&#xff09;会议是交通研究领域知名度最高学术会议之一&#xff0c;近年来的参会人数已经超过了2万名&#xff0c;是参与人数和国家最多的学术盛会。TRB会议几乎涵盖了交通领域…

### 【REST2SQL】07 GO 操作 Mysql 数据库

【REST2SQL】01RDB关系型数据库REST初设计 【REST2SQL】02 GO连接Oracle数据库 【REST2SQL】03 GO读取JSON文件 【REST2SQL】04 REST2SQL第一版Oracle版实现 【REST2SQL】05 GO 操作 达梦 数据库 【REST2SQL】06 GO 跨包接口重构代码 MySQL是一个关系型数据库管理系统&#xf…

### [开发语言][c++]：Static关键字和全局变量

Static关键字和全局变量 1. 生命周期、作用域和初始化时机2. 全局变量3. Static 关键字3.1 面向过程3.1.1 静态全局变量3.1.2 静态局部变量&#xff08;单例中会使用&#xff09;3.1.3 静态函数 3.2 面向对象3.2.1 类内静态成员变量3.2.2 类内静态成员函数 Reference 写在前面&…

### 【java八股文】之Spring系列篇

【java八股文】之JVM基础篇-CSDN博客 【java八股文】之MYSQL基础篇-CSDN博客 【java八股文】之Redis基础篇-CSDN博客 【java八股文】之Spring系列篇-CSDN博客 【java八股文】之分布式系列篇-CSDN博客 【java八股文】之多线程篇-CSDN博客 【java八股文】之JVM基础篇-CSDN博…

### ES6（ECMAScript 6.0）

ES6 学习链接ES6什么是ES6&#xff1f;ECMAScript 和 JavaScript 的关系 ECMAScript各版本新增特性ES6 块级作用域 let 学习链接 ES6简介 ECMAScript简介及特性&#xff08;科普&#xff01;很详细&#xff01;&#xff01;&#xff01;&#xff01;&#xff09; 20分钟上手ES…

### OpenHarmony基于HDF简单驱动开发实例

OpenHarmony基于HDF简单驱动开发实例 背景 OpenHarmony-3.0-LTS qemu_small_system_demo liteos_a qemu 添加配置 device/qemu/arm_virt/liteos_a/hdf_config/device_info/device_info.hcs device_info 新增&#xff1a; sample_host :: host {hostName "sample…

### Docker 配置国内镜像源加速

1. 国内镜像源总览 名称路径中国官方镜像https://registry.docker-cn.com网易163镜像http://hub-mirror.c.163.com中科大镜像https://docker.mirrors.ustc.edu.cn阿里云镜像https://[xxx].mirror.aliyuncs.com 2. 阿里云镜像源 地址&#xff1a;https://cr.console.aliyun.c…