//author: ycp | https://ycpedef.github.io //#pragma GCC diagnostic error "-std=c++11" //#pragma GCC optimize(2) #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cstdarg> #define debug(x) cerr << #x << " = " << x << endl #define debugf(...) fprintf(stderr, __VA_ARGS__) #define debugs(x) fputs(x"\n", stderr) usingnamespace std; template <classT> boolcmax(T &a, T b){ return b > a ? (a = b, 1) : 0; } template <classT> boolcmin(T &a, T b){ return b < a ? (a = b, 1) : 0; } template <classT> voidread(T &a){ a = 0; char c = getchar(); int f = 0; while (!isdigit(c)) { f ^= c == '-', c = getchar(); } while (isdigit(c)) { a = a * 10 + (c ^ 48), c = getchar(); } a *= f ? -1 : 1; } structFastin { template <classT> Fastin& operator >> (T &x) {read(x); return *this;} } fastin;
#define int long long
constint MAXN = 1010; constint mod = 100000007;
int n, p; int mul[MAXN], lum[MAXN]; structPoint { double x, y; booloperator < (Point a) { if (x == a.x) return y < a.y; elsereturn x < a.x; } } t[MAXN];
doublecross(Point a, Point b, Point c){ return (b.x - a.x) * (c.y - b.y) - (c.x - b.x) * (b.y - a.y); }
intpower(int a, int b){ int res = 1; while (b) { if (b & 1) { (res *= a) %= mod; } (a *= a) %= mod; b >>= 1; } return res; }
int ev, et;
signedmain(){ //freopen("forgive0.in", "r", stdin); //freopen("forgive0.ans", "w", stdout); cin >> n >> p; //debug(power(p, mod - 2)); ev = p * n % mod; for (int i = 1; i <= n; i++) { cin >> t[i].x >> t[i].y; } sort(t + 1, t + n + 1); for (int i = 1; i <= n; i++) { for (int j = i + 1, a, b; j <= n; j++) { a = 0, b = 0; for (int u = 1; u <= n; u++) { if (u == i || u == j) continue; if (cross(t[i], t[j], t[u]) < 0) { a++; } else { b++; } } //debugf("i = %lld, j = %lld, a = %lld, b = %lld\n", i, j, a, b); (et += p * p % mod * (power(mod + 1 - p, a) + power(mod + 1 - p, b)) % mod) %= mod; } } int ans = ev * 3 % mod - et - 3 + mod; //(ans += (1) * (power(mod + 1 - p, n - 1) * p % mod) % mod) %= mod; (ans += 3 * power(mod + 1 - p, n) % mod) %= mod; cout << ans << endl; return0; }
int n, m; map<pair<int, int>, int> g; vector<int> e[50010];
intmain(){ scanf("%d%d", &n, &m); for (int i = 1, x, y; i <= m; i++) { scanf("%d%d", &x, &y); e[x].push_back(y), e[y].push_back(x); } for (int p = 1; p <= n; p++) { for (auto u : e[p]) { if (u <= p) continue; for (auto v : e[p]) { if (u <= v) continue; g[make_pair(u, v)]++; } } } longlong ans = 0, v = 0; for (auto it : g) { v = it.second; if (v < 2) continue; ans = ans + v * (v - 1) / 2; } printf("%lld\n", ans); return0; }
T3 destiny
对于每个询问 q,只需要找出离它最近的 1 修改操作 p 和时间戳在 [p.t,q.t] 范围内的 2 操作取 min 即可。