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