fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. char ans[][22] = { "Incorrect", "Correct" };
  5. int low[2222], disc[2222], par[2222], vist[2222];
  6. vector<int> arr[2222];
  7. pair<int, int> bridg;
  8. void dfs(int x) {
  9. static int tim = 0;
  10. low[x] = disc[x] = ++tim;
  11. vist[x] = 1;
  12. for (int i = 0, ln = arr[x].size(); i < ln; ++i) {
  13. int y = arr[x][i];
  14. if (!vist[y]) {
  15. par[y] = x;
  16. dfs(y);
  17. low[x] = min(low[x], low[y]);
  18. if (low[y] <= disc[x]) {
  19. bridg = make_pair(min(x, y), max(x, y));
  20. }
  21. } else if (par[x] != y) {
  22. low[x] = min(low[x], disc[y]);
  23. }
  24. }
  25. }
  26. class TheKingsRoadsDiv2 {
  27. public:
  28. string getAnswer(int h, vector<int> a, vector<int> b) {
  29. int in[2222] = { };
  30. set<pair<int, int> > st;
  31. for (size_t i = 0; i < a.size(); ++i) {
  32. if (a[i] == b[i]
  33. || st.find(make_pair(min(a[i], b[i]), max(a[i], b[i])))
  34. != st.end()) {
  35. continue;
  36. }
  37. st.insert(make_pair(min(a[i], b[i]), max(a[i], b[i])));
  38. arr[a[i]].push_back(b[i]);
  39. arr[b[i]].push_back(a[i]);
  40. in[a[i]]++;
  41. in[b[i]]++;
  42. }
  43. memset(disc, -1, sizeof disc);
  44. dfs(1);
  45. for (int i = 1; i <= (1 << h) - 1; ++i) {
  46. if (!vist[i])
  47. return ans[0];
  48. }
  49. in[bridg.first]--;
  50. in[bridg.second]--;
  51. int cnt[3] = { };
  52. for (int i = 1; i <= (1 << h) - 1; ++i) {
  53. if (in[i] == 2)
  54. ++cnt[0];
  55. if (in[i] == 3)
  56. ++cnt[1];
  57. if (in[i] == 1)
  58. ++cnt[2];
  59. }
  60. return ans[cnt[0] == 1 && cnt[2] == (1 << (h - 1))];
  61. }
  62. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/lib/gcc/i586-linux-gnu/4.9/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty