Pagini recente » Cod sursa (job #19181) | Cod sursa (job #1644468) | Cod sursa (job #1684250) | Cod sursa (job #2726168) | Cod sursa (job #82752)
Cod sursa(job #82752)
#include <stdio.h>
const char iname[] = "count.in";
const char oname[] = "c:\\output.txt";
#define MAXN 30007
unsigned char *G[MAXN][128];
void add_edge(const int x, const int y)
{
if (G[x][y & 127] == 0) {
G[x][y & 127] = new unsigned char[256];
for (int i = 0; i < 256; ++ i)
G[x][y & 127][i] = 0;
}
G[x][y & 127][y >> 7] = 1;
}
int query_edge(const int x, const int y)
{
if (G[x][y & 127] == 0)
return 0;
return G[x][y & 127][y >> 7];
}
int main(void)
{
int n;
int n_edges;
int x, y;
FILE *fi = fopen(iname, "r");
fscanf(fi, "%d", &n);
fscanf(fi, "%d", &n_edges);
for (int i = 0; i < n_edges; ++ i) {
fscanf(fi, "%d %d", &x, &y);
add_edge(x, y);
add_edge(y, x);
}
fclose(fi);
return 0;
}