GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — CompetitiveProgramming/Topcoder/SRM779-D1-900.cpp at master · danh2006/CompetitiveProgramming

Expand file tree

/

SRM779-D1-900.cpp

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
47 lines (45 loc) · 975 Bytes
/

SRM779-D1-900.cpp

Copy path

File metadata and controls

47 lines (45 loc) · 975 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <bits/stdc++.h>
using namespace std;
#define ll long long
class ParadePlanner {
public:
bool g[500][500];
int p[500], d[500];
ll count(int n, int seed, int threshold, vector<int> toggle) {
for(int x=0; x<n; ++x) {
for(int y=x+1; y<n; ++y) {
seed=(seed*1103515245ll+12345)&((1ll<<31)-1);
if(seed<threshold)
g[x][y]=g[y][x]=1;
}
}
for(int i=0; i<toggle.size(); i+=2) {
int x=toggle[i], y=toggle[i+1];
g[x][y]^=1;
g[y][x]^=1;
}
ll ans=0;
for(int i=0; i<n; ++i)
for(int j=0; j<n; ++j)
d[i]+=g[i][j];
for(int i=0; i<n; ++i)
for(int j=0; j<n; ++j)
if(g[i][j])
p[i]+=d[j]-1;
for(int i=0; i<n; ++i) {
for(int j=i+1; j<n; ++j) {
int c=0;
for(int k=0; k<n; ++k)
c+=g[i][k]&&g[j][k];
ans-=2*c*(c-1);
if(g[i][j]) {
ans+=2ll*(p[i]-d[j]+1)*(p[j]-d[i]+1);
for(int k=j+1; k<n; ++k)
if(g[i][k]&&g[j][k])
ans-=6+6*(d[i]+d[j]+d[k]-6);
}
}
}
return ans;
}
};
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.