Pagini recente » Cod sursa (job #445371) | Cod sursa (job #313356) | Cod sursa (job #2783786) | Cod sursa (job #1634345) | Cod sursa (job #1742243)
#include <bits/stdc++.h>
#define bits(x) __builtin_popcount(x)
using namespace std;
const int MMAX = 66000, //:O
NMAX = 4100,
B = 16;
struct PII {
int x, y;
inline PII() { }
inline PII(int _x, int _y) {
x = _x;
y = _y;
}
};
class hpstream {
private:
static const int BMAX = 1<<17;
FILE *file;
int buff;
char str[BMAX];
inline char nextch(void) {
if(buff==BMAX) {
fread(str, 1, BMAX, file);
buff = 0;
}
return str[buff++];
}
public:
hpstream() {}
hpstream(const char *str) {
file = fopen(str, "r");
buff = BMAX;
}
inline hpstream &operator>> (int &arg) {
char ch;
arg = 0;
while(!isdigit(ch=nextch()));
arg=ch-'0';
while(isdigit((ch=nextch())))
arg=arg*10+ch-'0';
return *this;
}
void close(void) {
fclose(file);
}
};
int g[NMAX][NMAX/B];
PII e[MMAX];
int main(void) {
hpstream fs("triplete.in");
ofstream gs("triplete.out");
int n, m, ant;
ant = 0; ///(Antwort)
fs>>n>>m;
for(int i=1; i<=m; ++i) {
fs>>e[i].x>>e[i].y;
if(e[i].x < e[i].y)
swap(e[i].x, e[i].y);
g[e[i].x][e[i].y/B] |= 1 << (e[i].y % B);
}
for(int i=1; i<=m; ++i)
for(int j=0; j<=n/B; ++j)
ant+=bits(g[e[i].x][j]&g[e[i].y][j]);
gs<<ant<<'\n';
fs.close();
gs.close();
return 0;
}