this is my submission:https://mirror.codeforces.com/contest/1831/submission/213733972
iam getting error of SOE,if somebody experienced this error please help as this is my first time getting this error.
regards, vishesh.
# | User | Rating |
---|---|---|
1 | Radewoosh | 3759 |
2 | orzdevinwang | 3697 |
3 | jiangly | 3662 |
4 | Benq | 3644 |
5 | -0.5 | 3545 |
6 | ecnerwala | 3505 |
7 | tourist | 3486 |
8 | inaFSTream | 3478 |
9 | maroonrk | 3454 |
10 | Rebelz | 3415 |
# | User | Contrib. |
---|---|---|
1 | adamant | 173 |
2 | awoo | 167 |
3 | SecondThread | 163 |
3 | nor | 163 |
5 | BledDest | 162 |
5 | Um_nik | 162 |
7 | maroonrk | 161 |
8 | -is-this-fft- | 150 |
9 | Geothermal | 146 |
10 | TheScrasse | 143 |
this is my submission:https://mirror.codeforces.com/contest/1831/submission/213733972
iam getting error of SOE,if somebody experienced this error please help as this is my first time getting this error.
regards, vishesh.
In this submission :https://mirror.codeforces.com/contest/1775/submission/207782995 I am getting MLE i have scartched my head for hours and its still not resolving,can any comrade help this noob?
using namespace std;[contest:https://atcoder.jp/contests/abc282/tasks/abc282_d] map<int, list> mp; int colour[200005]; bool vis[200005]; bool bip = true; long long int ans=0; long long int ct=0; void colcomp(long long x, long long c); void init() { for (int i = 0; i < 200005; i++) { colour[i] = -1; vis[i] = false; } } void travel(long long n) {
for (int i = 1; i <= n; i++) { ct=1; if (vis[i] == false) { colcomp(i, 1); } if(ct!=1){ long long int k=ct/2; long long int c1=k; long long int c2=k+ct%2; ans-=(c1*(c1-1))/2; ans-=(c2*(c2-1))/2; } }
} void colcomp(long long x, long long c) {
vis[x] = true; colour[x] = c; for (auto it = mp[x].begin(); it != mp[x].end(); it++) { if (colour[*it] == -1){ ct++; colcomp(*it, 1 - c); } else { if (colour[*it] == colour[x]) { bip = false; } else { // do nothing } } }
}
int main() { #define int long long int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; mp[a].push_back(b); mp[b].push_back(a); } init(); travel(n); ans-=m; ans+=(n*(n-1))/2; if(!bip){ cout<<0<<endl; return 0; } cout<<ans<<endl; }
Name |
---|