fork download
  1. boolean[] vis;
  2. int[] ans;
  3. int pointer;
  4. void addEdge(int a, int b) {
  5. ans[pointer++] = a;
  6. ans[pointer++] = b;
  7. }
  8. public int[] findAnyGraph(int n, int m, int k) {
  9. int need = 1;
  10. for(int i = 0; i < k; ++i) {
  11. need *= 2;
  12. if(need > n) {
  13. int[] nothing = new int[1];
  14. nothing[0] = -1;
  15. return nothing;
  16. }
  17. }
  18. ans = new int[2*m];
  19. pointer = 0;
  20. int power_of_two = 1;
  21. for(int rep = 0; rep < k; ++rep) {
  22. for(int i = power_of_two; i <= need-1; i += 2*power_of_two)
  23. addEdge(i, i+1);
  24. power_of_two *= 2;
  25. }
  26. for(int i = 1; i <= n; ++i)
  27. for(int j = n; j >= i+1; --j)
  28. if(j > need || j > i+1)
  29. if(pointer < 2 * m)
  30. addEdge(i, j);
  31. return ans;
  32. }
  33.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:5: error: 'boolean' does not name a type
     boolean[] vis;
     ^
prog.cpp:2:8: error: expected unqualified-id before '[' token
     int[] ans;
        ^
prog.cpp: In function 'void addEdge(int, int)':
prog.cpp:5:9: error: 'ans' was not declared in this scope
         ans[pointer++] = a;
         ^
prog.cpp: At global scope:
prog.cpp:8:5: error: expected unqualified-id before 'public'
     public int[] findAnyGraph(int n, int m, int k) {
     ^
stdout
Standard output is empty