Skip to content

Commit

Permalink
windows
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou-yidie committed Oct 28, 2024
1 parent 01c958e commit a27728b
Show file tree
Hide file tree
Showing 256 changed files with 13,103 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: C/C++ CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: configure
run: ./configure
- name: make
run: make
- name: make check
run: make check
- name: make distcheck
run: make distcheck
28 changes: 28 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++-12 生成活动文件",
"command": "/usr/bin/g++-12",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}
124 changes: 124 additions & 0 deletions 01串线段树.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10 ;
string s ;
struct node {
int l , r ;
int v0 , v1 ;
int rev ;
}tr[ N * 4 ] ;

int len( node &r ) {
return r.r - r.l + 1 ;
}

void pushup( int u ) {
int Llen = len( tr[ u << 1 ]) , Rlen = len(tr[ u << 1 | 1 ]) ;
auto &L = tr[ u << 1 ] , &R = tr[ u << 1 | 1 ] , &RT = tr[ u ] ;
if ( Llen % 2 == 0 ) {
RT.v0 = L.v0 + R.v0 ;
RT.v1 = L.v1 + R.v1 ;
} else if( Llen % 2 != 0) {
RT.v0 = L.v0 + R.v1 ;
RT.v1 = L.v1 + R.v0 ;
}
}

node pushup( node &L , node &R ) {
node RT ;
RT.l = L.l , RT.r = R.r;
int Llen = len(L) , Rlen = len(R) ;
if ( Llen % 2 == 0 ) {
RT.v0 = L.v0 + R.v0 ;
RT.v1 = L.v1 + R.v1 ;
} else {
RT.v0 = L.v0 + R.v1 ;
RT.v1 = L.v1 + R.v0 ;
}
return RT ;
}

void build( int u , int l , int r ) {
tr[ u ] = { l , r } ;
if ( l == r ) {
tr[ u ].v0 = s[ r ] != '0' ;
tr[ u ].v1 = s[ r ] != '1' ;
tr[ u ].rev = 0 ;
return ;
}
int mid = ( l + r ) >> 1 ;
build( u << 1 , l , mid ) ;
build( u << 1 | 1 , mid + 1 , r ) ;
pushup( u ) ;
}

void pushdown( int u ) {
auto &L = tr[ u << 1 ] , &R = tr[ u << 1 | 1 ] , &RT = tr[ u ] ;
if (RT.rev) {
swap( L .v0 , L.v1 ) ;
L.rev ^= 1 ;
swap( R.v0 , R.v1 ) ;
R.rev ^= 1 ;
RT.rev = 0 ;
}
}

void modify( int u , int l , int r ) {
pushdown( u ) ;
if (l <= tr[ u ].l && tr[ u ].r <= r) {
swap( tr[u].v0 , tr[ u ].v1 ) ;
tr[ u ].rev ^= 1 ;
return;
}
int mid = (tr[ u ].l + tr[ u ].r ) >> 1 ;
if (l <= mid) {
modify( u << 1 , l , r ) ;
}
if( r > mid ) {
modify( u << 1 | 1 , l , r ) ;
}
pushup( u ) ;
}


node query( int u , int l , int r ) {
pushdown( u ) ;
if (l <= tr[ u ].l && tr[ u ].r <= r ) {
return tr[ u ] ;
}
int mid = ( tr[u].l + tr[u].r ) >> 1 ;
node L , R ;
if (r <= mid) {
return query( u << 1 , l , r ) ;
} else if ( l > mid ) {
return query( u << 1 | 1 , l , r ) ;
} else {
L = query( u << 1 , l , r ) ;
R = query( u << 1 | 1 , l , r ) ;
return pushup( L , R ) ;
}
}

int main( ) {
ios::sync_with_stdio( 0 ) ;
cin.tie( 0 ) ; cout.tie( 0 ) ;
int n , q ; cin >> n >> q >> s ;
s = '*' + s ;
build( 1 , 1 , n ) ;
while( q-- ) {
int op , l , r ;
cin >> op >> l >> r ;
if ( op == 1 ) {
modify( 1 , l , r ) ;
} else {
auto res = query( 1, l , r ) ;
cout << min( res.v0 , res.v1 ) << '\n';
}
}
return 0 ;
}





47 changes: 47 additions & 0 deletions 01矩阵.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
class Solution
{
private:
static constexpr int dirs[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

public:
vector<vector<int>> updateMatrix(vector<vector<int>>& matrix)
{
int m = matrix.size(), n = matrix[0].size();
vector<vector<int>> dist(m, vector<int>(n));
vector<vector<int>> seen(m, vector<int>(n));
queue<pair<int, int>> q;
// 将所有的 0 添加进初始队列中
for (int i = 0; i < m; ++i)
{
for (int j = 0; j < n; ++j)
{
if (matrix[i][j] == 0)
{
q.emplace(i, j);
seen[i][j] = 1;
}
}
}

// 广度优先搜索
while (!q.empty())
{
auto [i, j] = q.front();
q.pop();
for (int d = 0; d < 4; ++d)
{
int ni = i + dirs[d][0];
int nj = j + dirs[d][1];
if (ni >= 0 && ni < m && nj >= 0 && nj < n && !seen[ni][nj])
{
dist[ni][nj] = dist[i][j] + 1;
q.emplace(ni, nj);
seen[ni][nj] = 1;
}
}
}

return dist;
}
};

30 changes: 30 additions & 0 deletions 2023牛客国庆集训派对day7-H.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include<bits/stdc++.h>
#define eps 1e-5
using namespace std;
typedef long long ll;
const int mod=1e9+7;

int main(){

int t;
ll n,m,i=0,j=0,ans=0;
cin>>n>>m;
for(i=2;i<=m;i=j+1){
ll a=n;
if(i>a) break;
j=min(a/(a/i),m);
// cout << "i = " << i << " j = " << j << " sum = " << (j-i+1)*(a/i) << endl;
ans = (ans+(j-i+1)*(a/i))%mod;
}
for(i=2;i<=m;i=j+1)
{
ll a=n-1;
if(i>a) break;
j=min((a)/(a/i),m);
// cout << "i = " << i << " j = " << j << " sum = " << (j-i+1)*(a/i) << endl;
ans = (ans + (j - i + 1) * ( a / i )) % mod;
}
ans=(ans + m + n - 1) % mod;
printf("%lld\n",ans);
return 0;
}
97 changes: 97 additions & 0 deletions 2024ICPC网络赛E.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
#define int long long
#define ll long long
const ll N = 5e5 + 10;
const int inf = 0x3f3f3f3f;


void solve() {
int n, m, D;
cin >> n >> m >> D;
//assert(D > 0);

vector<vector<int>> E(n + 1);
vector<array<int, 2>> from(n+1,array<int, 2>{0,0});
vector<array<int, 2>> val(n+1,array<int, 2>{inf,inf});

while (m--) {
int u, v;
cin >> u >> v;
E[u].push_back(v);
E[v].push_back(u);
}

queue<pii> Q;

int k;
cin >> k;
while (k--) {
int x;
cin >> x;
//assert(x != 1);
val[x][0] = 0;
Q.push({ 0, x });
}

while (!Q.empty()) {
auto [d, u] = Q.front();
Q.pop();
if (d < D) {
++d;
for (auto& v : E[u]) {
if (val[v][d & 1] != inf) continue;
val[v][d & 1] = d;
Q.push({ d, v });
}
}
}

// from[1][0] = from[1][1] = -1;
Q.push({ 0, 1 });
while (!Q.empty()) {
auto [d, u] = Q.front();
Q.pop();

if (u == n) {
vector<int> path;
cout << d << '\n';
int u = n;
while (d>=0) {
path.push_back(u);
u = from[u][d & 1];
d--;
}

//assert(d == path.size() - 1);
//cout << path.size() - 1 << '\n';
for (int i = path.size() - 1; i >= 0; --i) {
cout << path[i] << ' ';
}
cout << '\n';
return;
}

++d;
for (auto& v : E[u]) {
if (d >= val[v][d & 1]) continue;
if (from[v][d & 1]) continue;
from[v][d & 1] = u;
Q.push({ d, v });
}
}

cout << "-1\n";
}

signed main() {
int T = 1;
cin >> T;

while (T--) {
solve();
}

return 0;
}
32 changes: 32 additions & 0 deletions CF104857F.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

inline int rd() {
int x = 0;
bool f = 0;
char c = getchar();
for (; !isdigit(c); c = getchar()) f |= (c == '-');
for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
return f ? -x : x;
}

#define eb emplace_back
#define all(s) (s).begin(), (s).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)

map<string, int> f;

int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n; cin >> n;
rep(i, 1, n) {string s; cin >> s; ++f[s];}
for (auto [s, cnt] : f) if (cnt * 2 > n) {
cout << s << endl; return 0;
}
cout << "uh-oh" << endl;
return 0;
}
Loading

0 comments on commit a27728b

Please sign in to comment.