wqzgg

5634

3k

Hasity
CC_15
acwing_gza
incra

yxc的小迷妹
h-h

ssy_

dream小健健

wqzgg
17小时前
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

const int N = 2010, M = 10010;

int n, m;
int h[N], w[M], e[M], ne[M], idx;
int dist[N], cnt[N];
bool st[N];

void add(int a, int b, int c)
{
e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++ ;
}

bool spfa()
{
queue<int> q;

for (int i = 1; i <= n; i ++ )
{
st[i] = true;
q.push(i);
}

while (q.size())
{
int t = q.front();
q.pop();

st[t] = false;

for (int i = h[t]; i != -1; i = ne[i])
{
int j = e[i];
if (dist[j] > dist[t] + w[i])
{
dist[j] = dist[t] + w[i];
cnt[j] = cnt[t] + 1;

if (cnt[j] >= n) return true;
if (!st[j])
{
q.push(j);
st[j] = true;
}
}
}
}

return false;
}

int main()
{
scanf("%d%d", &n, &m);

memset(h, -1, sizeof h);

while (m -- )
{
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
}

if (spfa()) puts("Yes");
else puts("No");

return 0;
}


wqzgg
2天前
#include <bits/stdc++.h>

using namespace std;
const int N = 100010, M = N, INF = 0x3f3f3f3f;
int n,m;
int h[N], e[M], w[N], ne[M], idx;
int dist[N], q[N];
bool st[N];

void add(int a, int b, int c)
{
e[idx] = b,w[idx] = c,ne[idx] = h[a],h[a] = idx++;
}
int spfa()
{
memset(dist, 0x3f, sizeof dist);
int hh = 0, tt = 0;
q[tt ++ ] = 1;
dist[1] = 0;
while (hh != tt)
{
int t = q[hh ++ ];
if (hh == N) hh = 0;
st[t] = false;
for (int i = h[t]; i != -1; i = ne[i])
{
int j = e[i];
if (dist[j] > dist[t] + w[i])
{
dist[j] = dist[t] + w[i];
if (!st[j])
{
q[tt ++ ] = j;
if (tt == N) tt = 0;
st[j] = true;
}
}
}
}
return dist[n];
}
int main()
{
cin >> n >> m;
memset(h,-1, sizeof h);
while(m--)
{
int a,b, c;
cin >> a >> b >> c;
}
int res = spfa();
if(res == INF)puts("impossible");
else cout << res;
}


wqzgg
3天前
#include <bits/stdc++.h>

using namespace std;

const int N = 150010, INF = 0x3f3f3f3f;
int ne[N], e[N], w[N], h[N], idx;
int n,m;
int dist[N];
bool st[N];

void add(int a, int b, int c)
{
w[idx] = c;
e[idx] = b;
ne[idx] = h[a];
h[a] = idx ++ ;
}
int dijkstra()
{
memset(dist, INF, sizeof dist);
dist[1] = 0;
priority_queue<PII, vector<PII>, greater<PII>> heap;
heap.push({1,0});
while (heap.size())
{
int t = heap.top().second;
heap.pop();
if (st[t]) continue;
st[t] = true;
for (int i = h[t]; ~i; i = ne[i])
{
int j = e[i];
if (dist[j] > dist[t] + w[i])
{
dist[j] = dist[t] + w[i];
heap.push({dist[j],j})
}
}
}
return dist[n];
}
int main()
{
cin >> n >> m;
for (int i = 0; i < n; i ++ )
{
int a,b,c;
cin >> a >> b >> c;
}
int t = dijkstra();
if (t == INF) puts("-1");
else cout << t << endl;
}



wqzgg
4天前
#include <bits/stdc++.h>
using namespace std;
int main(){long long n;cin >> n;cout << n / 2520;}


wqzgg
7天前
#include <bits/stdc++.h>

using namespace std;

int main()
{
int n, f[510][510];
cin >> n;
for (int i= 1; i <= n;i++)
for (int j = 1; j <= i; j++)
cin >> f[i][j];
while (n -- )
{
for (int i = 1; i <= n; i ++ )
f[n][i] += max(f[n+1][i+1], f[n+1][i]);
}
cout << f[1][1];
}


wqzgg
8天前
#include <bits/stdc++.h>

using namespace std;

int num[10] = {1,2,3,4,5,6,7,8,9};
int cal(int l, int r)
{
int res = 0;
for (int i =l + 1; i <= r; i ++ )
{
res = res * 10 + num[i];
}
return res;
}
int main()
{
int ter, res = 0;
cin >> ter;
do
{
for (int i = 0; i < 9; i ++ )
for (int j = i + 1; j < 9; j ++ )
{
int a = cal(-1, i);
int b = cal(i, j);
int c = cal(j, 8);
if (ter * c == a * c + b) res ++ ;
}
}while(next_permutation(num, num + 9));
cout << res;
}


wqzgg
9天前

wqzgg
10天前
https://www.acwing.com/solution/content/177787/ hhhhhhh

wqzgg
10天前
#incl\
ude\
<iostream>

us\
ing \
namespace \
std;

int \
main()
{
int \
a,b;

cin >> a >> b;
cout << (a + \
b);
}

#i\
n\
c\
l\
ud\
e\
<i\
o\
stre\
am>

us\
in\
g \
nam\
espace \
std;

in\
t \
mai\
n()
{
int \
a,\
b;

cin >>\
a >>\
b;
cout <<\
(a + \
b);
}

#include <iostream>
#define u u\
s\
i\
n\
g \
n\
a\
m\
e\
s\
p\
ace std;
#define i i\
nt ma\
in(){
#define n i\
nt a,\
b;
#define c ci\
n >> a\
>> b;
#define o co\
ut << a\
+ b << en\
dl;
#define r r\
etur\
n \
0;}
u
i
n
c
o
r


+

#pragma GCC diagno\
stic error "-std=c++11"
#pragma GCC tar\
get("avx")
#pragma GCC opti\
mize(1)
#pragma GCC opt\
imize(2)
#pragma GCC opti\
mize(3)
#pragma GC\
C optimize("Ofast")
#pr\
agma GCC optimize("inline")
#pragma GCC opti\
mize("-fgcse")
#pragma GCC optim\
ize("-fgcse-lm")
#pragma GCC optimiz\
e("-fipa-sra")
#pragma GCC optim\
ize("-ftree-pre")
#pragma GCC optim\
ize("-ftree-vrp")
#pragma GCC optimi\
ze("-fpeephole2")
#pragma GCC optimi\
ze("-ffast-math")
#pragma GCC optim\
ize("-fsched-spec")
#pragma GCC opt\
imize("unroll-loops")
#pragma GCC opt\
imize("-falign-jumps")
#pragma GCC opti\
mize("-falign-loops")
#pragma GCC opti\
mize("-falign-labels")
#pragma GCC o\
ptimize("-fdevirtualize")
#pragma GCC op\
timize("-fcaller-saves")
#pragma GCC opt\
imize("-fcrossjumping")
#pragma GCC opti\
#pragma GCC optim\
ize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#prag\
ma GCC optimize("-ftree-tail-merge")
#pragma GC\
C optimize("-fschedule-insns2")
#pragma GCC opti\
mize("-fstrict-aliasing")
#pragma GC\
C optimize("-fst\
rict-overflow")
#pragma GCC optimize("-fali\
gn-functions")
#pragma GCC optimize("-fcse-\
skip-blocks")
#pragma GCC optimize("-fcse-\
follow-jumps")
#pragma GCC optimize("-fsched\
-interblock")
#pragma GCC optimize("-fparti\
al-inlining")
#pragma GCC optimize("no-stack-p\
rotector")
#pragma GCC optimize("-freorder-fun\
ctions")
#pragma GCC opti\
mize("-findirect-inlining")
#pragma GCC o\
#pragma GCC optim\
ize("-frerun-cse-after-loop")
#pragma GCC opt\
imize("inline-small-functions")
#pragma GCC optimize("\
-finline-small-functions")
#pragma GCC optimize("\
-ftree-switch-conversion")
#pragma GCC optim\
ize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexp\
ensive-optimizations")
#pragma GCC optimize("-funsafe-loo\
p-optimizations")
#pragma GCC optimize("inline-functi\
ons-called-once")
#pragma GCC optimi\
ze("-fdelete-null-pointer-checks")
#include<bits/st\
dc++.h>
#include <algo\
rithm>
#include <bits\
et>
#include <cct\
ype>
#include <cer\
rno>
#include <c\
float>
#include <ci\
so646>
#include <cl\
imits>
#include <clo\
cale>
#include <\
cmath>
#include <c\
omplex>
#include <cs\
ignal>
#include <cset\
jmp>
#include <cst\
darg>
#include <cst\
ddef>
#include <cst\
dio>
#include <cstdl\
ib>
#include <cstri\
ng>
#include <cti\
me>
#include <cw\
char>
#include <cwc\
type>
#include <deq\
ue>
#include <exc\
eption>
#include <fst\
ream>
#include <funct\
ional>
#include <limi\
ts>
#include <list\
>
#include <loc\
ale>
#include <map>
#i\
nclude <m\
emory>
#inclu\
de <new>
#inclu\
de <numeric>
#inclu\
de <iomanip>
#inclu\
de <ios>
#include <io\
sfwd>
#include <io\
stream>
#in\
clude <istr\
eam>
#inclu\
de <ite\
rator>
#include <ostream>
#inclu\
de <queue>
#inclu\
de <set>
#inc\
lude <ss\
tream>
#incl\
ude <st\
ack>
#inclu\
de <stdexc\
ept>
#in\
clude <str\
eambuf>
#i\
nclude <string>
#inc\
lude <typeinfo>
#inc\
lude <utility>
#incl\
ude <valarray>
#inclu\
de <vector>
#inc\
lude <bits/c++config.h>
#inc\
lude <bits/functexcept.h>
#inc\
lude <bits/cpp_type_traits.h>
#inc\
lude <ext/type_traits.h>
#inc\
lude <ext/numeric_traits.h>
#inc\
lude <bits/stl_pair.h>
#incl\
ude <bits/stl_iterator_base_types.h>
#inclu\
de <bits/stl_iterator_base_funcs.h>
#include \
<bits/stl_it\
erator.h>
#include <b\
its/concept_check.h>
#include <deb\
ug/debug.h>
#include <bits\
/move.h>


wqzgg
10天前