Diff
checker
Texte
Texte
Images
Documents
Excel
Dossiers
Legal
Enterprise
Application de bureau
Prix
Se connecter
Télécharger Diffchecker Desktop
Comparer le texte
Trouver la différence entre deux fichiers texte
Outils
Historique
Éditeur live
Cacher identiques
Sans retour à la ligne
Vue
Divisé
Unifié
Niveau de précision
Intelligent
Mot
Caractère
Coloration syntaxique
Choisir la syntaxe
Ignorer
Transformer le texte
Aller au premier écart
Modifier l'entrée
Diffchecker Desktop
La façon la plus sécurisée d'utiliser Diffchecker. Obtenez l'application Diffchecker Desktop : vos diffs ne quittent jamais votre ordinateur !
Obtenir Desktop
Untitled diff
Créé
il y a 9 ans
Le diff n'expire jamais
Effacer
Exporter
Partager
Expliquer
43 suppressions
Lignes
Total
Supprimé
Caractères
Total
Supprimé
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
157 lignes
Copier tout
32 ajouts
Lignes
Total
Ajouté
Caractères
Total
Ajouté
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
145 lignes
Copier tout
Copier
Copié
Copier
Copié
#include
<cstdio>
#include
<bits/stdc++.h>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#define maxn 600009
using namespace std;
using namespace std;
Copier
Copié
Copier
Copié
int
UU
[maxn],
VV
[maxn],
WW
[maxn], q[maxn];
const
int
maxn= 600100;
using namespace std;
int a
[maxn],
b
[maxn],
c
[maxn], q[maxn];
typedef struct
typedef struct
{
{
int l,r;
int l,r;
Copier
Copié
Copier
Copié
}node
;
}node
1
;
node
seg[maxn];
node
1
seg[maxn];
typedef struct
typedef struct
{
{
int u,v,w,id;
int u,v,w,id;
Copier
Copié
Copier
Copié
}node
1
;
}node
2
;
node
1
edge[maxn];
node
2
edge[maxn];
bool cmp(node
1
x,node
1
y)
bool cmp(node
2
x,node
2
y)
{
{
return x.w<y.w;
return x.w<y.w;
}
}
int p[maxn];
int p[maxn];
int findset(int x)
int findset(int x)
{
{
return x==p[x]?x:p[x]=findset(p[x]);
return x==p[x]?x:p[x]=findset(p[x]);
}
}
void unionset(int x,int y)
void unionset(int x,int y)
{
{
p[findset(x)]=findset(y);
p[findset(x)]=findset(y);
}
}
int vis[maxn];
int vis[maxn];
bool wa[maxn];
bool wa[maxn];
set<int>st;
set<int>st;
struct Edge
struct Edge
{
{
int to,id;
int to,id;
};
};
vector<Edge>G[maxn];
vector<Edge>G[maxn];
int type[maxn];
int type[maxn];
map<int, int>mp;
map<int, int>mp;
Copier
Copié
Copier
Copié
vector< vector<int> > V[maxn];
vector< vector<int> > V[maxn];
vector<int>tmp[maxn], cr;
vector<int>tmp[maxn], cr;
vector<int>buf;
vector<int>buf;
bool NO[maxn];
bool NO[maxn];
Copier
Copié
Copier
Copié
int fdset(int x){
int fdset(int x){
return q[x] == x ? x : q[x] = fdset(q[x]);
return q[x] == x ? x : q[x] = fdset(q[x]);
}
}
void unset(int x, int y){
void unset(int x, int y){
q[fdset(x)] = fdset(y);
q[fdset(x)] = fdset(y);
}
}
void doit(vector <int> &G){
void doit(vector <int> &G){
cr.clear();
cr.clear();
int lb = G[0];
int lb = G[0];
for(int j = 1; j < (int)G.size(); j++){
for(int j = 1; j < (int)G.size(); j++){
Copier
Copié
Copier
Copié
int u =
UU
[G[j]]
;
int u =
a
[G[j]]
,
v =
b
[G[j]];
int
v =
VV
[G[j]];
u = findset(u);
v = findset(v);
u = findset(u);
v = findset(v);
if(fdset(u) == fdset(v)){
if(fdset(u) == fdset(v)){
NO[lb] = 1;
NO[lb] = 1;
}
}
unset(u, v);
unset(u, v);
Copier
Copié
Copier
Copié
cr.push_back(u);
cr.push_back(u);
cr.push_back(v);
cr.push_back(v);
if(NO[lb])
break;
if(NO[lb])
break;
}
}
Copier
Copié
Copier
Copié
for(auto x: cr)
for(auto x: cr)
q[x] = x;
q[x] = x;
}
}
void check(int x){
void check(int x){
for(int i = 0; i < (int)V[x].size(); i++){
for(int i = 0; i < (int)V[x].size(); i++){
doit(V[x][i]);
doit(V[x][i]);
}
}
}
}
int main()
int main()
{
{
int n,m;
int n,m;
scanf("%d%d",&n,&m);
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
for(int i=1;i<=n;i++){
Copier
Copié
Copier
Copié
p[i]=i;
p[i]=i;
q[i] = i;
q[i] = i;
}
}
for(int i=0;i<m;i++)
for(int i=0;i<m;i++)
{
{
scanf("%d%d%d",&edge[i].u,&edge[i].v,&edge[i].w);
scanf("%d%d%d",&edge[i].u,&edge[i].v,&edge[i].w);
Copier
Copié
Copier
Copié
UU[i +
1] = edge[i].u;
a[i+
1] = edge[i].u;
VV[i +
1] = edge[i].v;
b[i+
1] = edge[i].v;
WW[i +
1] = edge[i].w;
c[i+
1] = edge[i].w;
edge[i].id=i+1;
edge[i].id=i+1;
}
}
sort(edge,edge+m,cmp);
sort(edge,edge+m,cmp);
int cur=0,tot=0;
int cur=0,tot=0;
while(cur<m)
while(cur<m)
{
{
seg[tot].l=cur;
seg[tot].l=cur;
while(cur+1<m&&edge[cur].w==edge[cur+1].w)
while(cur+1<m&&edge[cur].w==edge[cur+1].w)
cur++;
cur++;
seg[tot].r=cur;
seg[tot].r=cur;
mp[edge[cur].w] = tot;
mp[edge[cur].w] = tot;
cur++;tot++;
cur++;tot++;
}
}
Copier
Copié
Copier
Copié
int
Q
;
int
q
;
scanf("%d", &
Q
);
scanf("%d", &
q
);
for(int i = 1; i <=
Q
; i++){
for(int i = 1; i <=
q
; i++){
buf.clear();
buf.clear();
buf.push_back(i);
buf.push_back(i);
cr.clear();
cr.clear();
int num;
int num;
scanf("%d", &num);
scanf("%d", &num);
for(int j = 0; j < num; j++){
for(int j = 0; j < num; j++){
int x;
int x;
scanf("%d", &x);
scanf("%d", &x);
Copier
Copié
Copier
Copié
int w = mp[
WW
[x]];
int w = mp[
c
[x]];
if((int)tmp[w].size() == 0){
if((int)tmp[w].size() == 0){
tmp[w].push_back(i);
tmp[w].push_back(i);
tmp[w].push_back(x);
tmp[w].push_back(x);
cr.push_back(w);
cr.push_back(w);
}
}
else{
else{
tmp[w].push_back(x);
tmp[w].push_back(x);
}
}
buf.push_back(x);
buf.push_back(x);
}
}
for(auto x: cr){
for(auto x: cr){
V[x].push_back(tmp[x]);
V[x].push_back(tmp[x]);
tmp[x].clear();
tmp[x].clear();
}
}
doit(buf);
doit(buf);
}
}
Copier
Copié
Copier
Copié
//cout << tot << endl;
for(int i=0;i<tot;i++)
for(int i=0;i<tot;i++)
{
{
check(i);
check(i);
for(int j = seg[i].l; j <= seg[i].r; j++){
for(int j = seg[i].l; j <= seg[i].r; j++){
unionset(edge[j].u, edge[j].v);
unionset(edge[j].u, edge[j].v);
}
}
}
}
Copier
Copié
Copier
Copié
for(int i = 1; i <=
Q
; i++)
for(int i = 1; i <=
q
; i++)
if(NO[i])
{
if(NO[i])
{
puts("NO");
puts("NO");
Copier
Copié
Copier
Copié
else
}
else
{
puts("YES");
puts("YES");
Copier
Copié
Copier
Copié
}
}
return 0;
return 0;
}
}
Différences enregistrées
Texte d'origine
Ouvrir un fichier
#include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <iostream> #include <vector> #include <map> #include <set> #define maxn 600009 using namespace std; int UU[maxn], VV[maxn], WW[maxn], q[maxn]; typedef struct { int l,r; }node; node seg[maxn]; typedef struct { int u,v,w,id; }node1; node1 edge[maxn]; bool cmp(node1 x,node1 y) { return x.w<y.w; } int p[maxn]; int findset(int x) { return x==p[x]?x:p[x]=findset(p[x]); } void unionset(int x,int y) { p[findset(x)]=findset(y); } int vis[maxn]; bool wa[maxn]; set<int>st; struct Edge { int to,id; }; vector<Edge>G[maxn]; int type[maxn]; map<int, int>mp; vector< vector<int> > V[maxn]; vector<int>tmp[maxn], cr; vector<int>buf; bool NO[maxn]; int fdset(int x){ return q[x] == x ? x : q[x] = fdset(q[x]); } void unset(int x, int y){ q[fdset(x)] = fdset(y); } void doit(vector <int> &G){ cr.clear(); int lb = G[0]; for(int j = 1; j < (int)G.size(); j++){ int u = UU[G[j]]; int v = VV[G[j]]; u = findset(u); v = findset(v); if(fdset(u) == fdset(v)){ NO[lb] = 1; } unset(u, v); cr.push_back(u); cr.push_back(v); if(NO[lb]) break; } for(auto x: cr) q[x] = x; } void check(int x){ for(int i = 0; i < (int)V[x].size(); i++){ doit(V[x][i]); } } int main() { int n,m; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++){ p[i]=i; q[i] = i; } for(int i=0;i<m;i++) { scanf("%d%d%d",&edge[i].u,&edge[i].v,&edge[i].w); UU[i + 1] = edge[i].u; VV[i + 1] = edge[i].v; WW[i + 1] = edge[i].w; edge[i].id=i+1; } sort(edge,edge+m,cmp); int cur=0,tot=0; while(cur<m) { seg[tot].l=cur; while(cur+1<m&&edge[cur].w==edge[cur+1].w) cur++; seg[tot].r=cur; mp[edge[cur].w] = tot; cur++;tot++; } int Q; scanf("%d", &Q); for(int i = 1; i <= Q; i++){ buf.clear(); buf.push_back(i); cr.clear(); int num; scanf("%d", &num); for(int j = 0; j < num; j++){ int x; scanf("%d", &x); int w = mp[WW[x]]; if((int)tmp[w].size() == 0){ tmp[w].push_back(i); tmp[w].push_back(x); cr.push_back(w); } else{ tmp[w].push_back(x); } buf.push_back(x); } for(auto x: cr){ V[x].push_back(tmp[x]); tmp[x].clear(); } doit(buf); } //cout << tot << endl; for(int i=0;i<tot;i++) { check(i); for(int j = seg[i].l; j <= seg[i].r; j++){ unionset(edge[j].u, edge[j].v); } } for(int i = 1; i <= Q; i++) if(NO[i]) puts("NO"); else puts("YES"); return 0; }
Texte modifié
Ouvrir un fichier
#include<bits/stdc++.h> using namespace std; const int maxn= 600100; using namespace std; int a[maxn], b[maxn], c[maxn], q[maxn]; typedef struct { int l,r; }node1; node1 seg[maxn]; typedef struct { int u,v,w,id; }node2; node2 edge[maxn]; bool cmp(node2 x,node2 y) { return x.w<y.w; } int p[maxn]; int findset(int x) { return x==p[x]?x:p[x]=findset(p[x]); } void unionset(int x,int y) { p[findset(x)]=findset(y); } int vis[maxn]; bool wa[maxn]; set<int>st; struct Edge { int to,id; }; vector<Edge>G[maxn]; int type[maxn]; map<int, int>mp; vector< vector<int> > V[maxn]; vector<int>tmp[maxn], cr; vector<int>buf; bool NO[maxn]; int fdset(int x){ return q[x] == x ? x : q[x] = fdset(q[x]); } void unset(int x, int y){ q[fdset(x)] = fdset(y); } void doit(vector <int> &G){ cr.clear(); int lb = G[0]; for(int j = 1; j < (int)G.size(); j++){ int u = a[G[j]], v = b[G[j]]; u = findset(u);v = findset(v); if(fdset(u) == fdset(v)){ NO[lb] = 1; } unset(u, v); cr.push_back(u);cr.push_back(v); if(NO[lb])break; } for(auto x: cr)q[x] = x; } void check(int x){ for(int i = 0; i < (int)V[x].size(); i++){ doit(V[x][i]); } } int main() { int n,m; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++){ p[i]=i;q[i] = i; } for(int i=0;i<m;i++) { scanf("%d%d%d",&edge[i].u,&edge[i].v,&edge[i].w); a[i+1] = edge[i].u; b[i+1] = edge[i].v; c[i+1] = edge[i].w; edge[i].id=i+1; } sort(edge,edge+m,cmp); int cur=0,tot=0; while(cur<m) { seg[tot].l=cur; while(cur+1<m&&edge[cur].w==edge[cur+1].w) cur++; seg[tot].r=cur; mp[edge[cur].w] = tot; cur++;tot++; } int q; scanf("%d", &q); for(int i = 1; i <= q; i++){ buf.clear();buf.push_back(i); cr.clear(); int num; scanf("%d", &num); for(int j = 0; j < num; j++){ int x; scanf("%d", &x); int w = mp[c[x]]; if((int)tmp[w].size() == 0){ tmp[w].push_back(i); tmp[w].push_back(x); cr.push_back(w); } else{ tmp[w].push_back(x); } buf.push_back(x); } for(auto x: cr){ V[x].push_back(tmp[x]); tmp[x].clear(); } doit(buf); } for(int i=0;i<tot;i++) { check(i); for(int j = seg[i].l; j <= seg[i].r; j++){ unionset(edge[j].u, edge[j].v); } } for(int i = 1; i <= q; i++) { if(NO[i]){ puts("NO"); } else{ puts("YES"); } } return 0; }
Trouver la différence