fork download
  1. using namespace std;
  2.  
  3. //mudar file.in pelo nome do input e por FILE_IN
  4. //antes dos scanfs
  5. #define FILE_IN freopen("file.in", "r", stdin);
  6.  
  7. #define fr(i,n) for(int i=0;i<n;i++)
  8. #define frr(i,a,b) for(int i =a;i<=b;i++)
  9. // for(auto it : g[i].nb)
  10.  
  11. typedef long long ll;
  12. typedef long double ld;
  13.  
  14. #define pb push_back
  15.  
  16. #define all(a) a.begin(),a.end()
  17.  
  18. #define fi first
  19. #define se second
  20. typedef pair<int,int> pii;
  21.  
  22. #define PI acos(-1)
  23. ll MOD = 1e9+7;
  24.  
  25. //LONG_LONG_MAX
  26. //-DBL_MAX
  27.  
  28. bool debug = 0;
  29. #define printa(a) cout << #a << " = " << (a) << endl
  30. #define prin(a) if(debug) cout << #a << " = " << (a) << endl
  31. #define prinsep if(debug) cout << "------" << endl;
  32. #define cendl if(debug) cout << endl
  33.  
  34. class oin{
  35. public:
  36. bool mais;
  37. int k;
  38. vector<int> v;
  39. };
  40.  
  41. vector<oin> v;
  42.  
  43. string ss(int i){
  44. if(i==0){
  45. return string("project");
  46. } else{
  47. string s = "object";
  48. s+= to_string(i);
  49. return s;
  50. }
  51. }
  52.  
  53. void dfs(int ii, int niv){
  54. string sout;
  55. fr(i,niv){
  56. sout+=" ";
  57. }
  58.  
  59. if(v[ii].k){
  60. if(v[ii].mais){
  61. sout[sout.size()-2] = '+';
  62. } else{
  63. sout[sout.size()-2] = '-';
  64. }
  65. }
  66. sout+=ss(ii);
  67. printf("%s\n", sout.c_str());
  68. if(!v[ii].mais){
  69. for(auto it : v[ii].v){
  70. dfs(it,niv+1);
  71. }
  72. }
  73. return;
  74. }
  75.  
  76. int main(){
  77. int n;
  78. scanf("%d", &n);
  79. v.resize(n+1);
  80.  
  81. fr(i,n+1){
  82. char c;
  83. int k;
  84. scanf(" %c %d", &c, &k);
  85. if(c=='+') v[i].mais = 1;
  86. else v[i].mais = 0;
  87.  
  88. v[i].k = k;
  89. v[i].v.resize(k);
  90. fr(j,k){
  91. scanf("%d", &v[i].v[j]);
  92. }
  93. }
  94.  
  95. /*
  96. string s = "oi";
  97. s+=to_string(100);
  98. s+= " oi";
  99. cout << s << endl;
  100. return 0;
  101. */
  102.  
  103. dfs(0,1);
  104.  
  105. return 0;
  106. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:20:9: error: ‘pair’ does not name a type
 typedef pair<int,int> pii;
         ^~~~
prog.cpp:38:2: error: ‘vector’ does not name a type
  vector<int> v;
  ^~~~~~
prog.cpp:41:1: error: ‘vector’ does not name a type
 vector<oin> v;
 ^~~~~~
prog.cpp:43:1: error: ‘string’ does not name a type
 string ss(int i){
 ^~~~~~
prog.cpp: In function ‘void dfs(int, int)’:
prog.cpp:54:2: error: ‘string’ was not declared in this scope
  string sout;
  ^~~~~~
prog.cpp:56:3: error: ‘sout’ was not declared in this scope
   sout+="  ";
   ^~~~
prog.cpp:59:5: error: ‘v’ was not declared in this scope
  if(v[ii].k){
     ^
prog.cpp:61:4: error: ‘sout’ was not declared in this scope
    sout[sout.size()-2] = '+';
    ^~~~
prog.cpp:63:4: error: ‘sout’ was not declared in this scope
    sout[sout.size()-2] = '-';
    ^~~~
prog.cpp:66:2: error: ‘sout’ was not declared in this scope
  sout+=ss(ii);
  ^~~~
prog.cpp:66:13: error: ‘ss’ was not declared in this scope
  sout+=ss(ii);
             ^
prog.cpp:67:29: error: ‘printf’ was not declared in this scope
  printf("%s\n", sout.c_str());
                             ^
prog.cpp:68:6: error: ‘v’ was not declared in this scope
  if(!v[ii].mais){
      ^
prog.cpp: In function ‘int main()’:
prog.cpp:78:16: error: ‘scanf’ was not declared in this scope
  scanf("%d", &n);
                ^
prog.cpp:79:2: error: ‘v’ was not declared in this scope
  v.resize(n+1);
  ^
stdout
Standard output is empty