fork download
  1. // ~~ icebear ~~
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. #define int long long
  5. typedef long long ll;
  6. typedef pair<int, int> ii;
  7. typedef pair<int, ii> iii;
  8.  
  9. template<class T>
  10. bool minimize(T &a, const T &b) {
  11. if (a > b) return a = b, true;
  12. return false;
  13. }
  14.  
  15. template<class T>
  16. bool maximize(T &a, const T &b) {
  17. if (a < b) return a = b, true;
  18. return false;
  19. }
  20.  
  21. #define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
  22. #define FORR(i,a,b) for(int i=(a); i>=(b); --i)
  23. #define REP(i, n) for(int i=0; i<(n); ++i)
  24. #define RED(i, n) for(int i=(n)-1; i>=0; --i)
  25. #define MASK(i) (1LL << (i))
  26. #define BIT(S, i) (((S) >> (i)) & 1)
  27. #define mp make_pair
  28. #define pb push_back
  29. #define fi first
  30. #define se second
  31. #define all(x) x.begin(), x.end()
  32. #define task "icebear"
  33.  
  34. const int MOD = 1e9 + 7;
  35. const int inf = 1e9 + 27092008;
  36. const ll INF = 1e18 + 27092008;
  37. const int N = 2e5 + 5;
  38.  
  39. mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());
  40. int random(int L, int R) {
  41. return L + rd() % (R - L + 1);
  42. }
  43.  
  44. vector<int> G[N];
  45. int t;
  46. bool vis[N];
  47. void dfs(int u, int s) {
  48. if (u != s) t = u;
  49. vis[u] = true;
  50. for(int v : G[u]) if (!vis[v]) dfs(v, s);
  51. }
  52.  
  53. void gen(int i) {
  54. ofstream cout("gen.inp");
  55. int n = random(1, 10000), m = random(1, 100000), k = random(1, 300);
  56. vector<pair< pair<int, int>, int> > edges;
  57. FOR(i, 1, m) {
  58. int u = random(1, n);
  59. int v = random(1, n);
  60. int w = random(1, 1000);
  61. edges.pb({{u, v}, w});
  62. G[u].pb(v);
  63. }
  64. int S = -1, T = -1;
  65. FOR(i, 1, n) {
  66. t = -1;
  67. dfs(i, i);
  68. if (t != -1) {
  69. S = i;
  70. T = t;
  71. break;
  72. }
  73. vis[i] = false;
  74. }
  75. if (S == -1) {
  76. S = random(1, n);
  77. T = random(1, n);
  78. }
  79. cout << n << ' ' << m << ' ' << k << ' ' << S << ' ' << T << '\n';
  80. FOR(i, 1, m) {
  81. cout << edges[i - 1].fi.fi << ' ' << edges[i - 1].fi.se << ' ' << edges[i - 1].se << '\n';
  82. }
  83. FOR(i, 1, k) {
  84. int u, v, w;
  85. u = random(1, n);
  86. v = random(1, n);
  87. w = random(1, n);
  88. cout << u << ' ' << v << ' ' << w << '\n';
  89. }
  90. FOR(i, 1, n) G[i].clear();
  91. FOR(i, 1, n) vis[i] = false;
  92. cout.close();
  93. }
  94.  
  95. void process(void) {
  96. FOR(i, 1, 50) {
  97. gen(i);
  98.  
  99. system("task.exe");
  100. system("task_trau.exe");
  101.  
  102. cout << "#Test " << i << ": ";
  103. if (system("fc gen.out gen.ans")) {
  104. cout << "WRONG!\n";
  105. exit(0);
  106. } else cout << "PASS!\n";
  107. }
  108. }
  109.  
  110. signed main() {
  111. ios_base::sync_with_stdio(0);
  112. cin.tie(0); cout.tie(0);
  113. if (fopen(task".inp", "r")) {
  114. freopen(task".inp", "r", stdin);
  115. freopen(task".out", "w", stdout);
  116. }
  117. int tc = 1;
  118. // cin >> tc;
  119. while(tc--) {
  120. process();
  121. }
  122. return 0;
  123. }
  124.  
Success #stdin #stdout #stderr 0.01s 8432KB
stdin
Standard input is empty
stdout
#Test 1: WRONG!
stderr
sh: 1: task.exe: not found
sh: 1: task_trau.exe: not found
sh: 1: fc: not found