Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.23 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define TRACE(x) x
  6. #define WATCH(x) TRACE( cout << #x" = " << x << endl)
  7. #define PRINT(x) TRACE(printf(x))
  8. #define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl;)
  9. #define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
  10. #define rep(i, a, b) for(int i = (a); i < (b); ++i)
  11. #define trav(a, x) for(auto& a : x)
  12. #define all(x) (x).begin(), (x).end()
  13. #define sz(x) (int)(x).size()
  14. #define mp make_pair
  15. #define fi first
  16. #define se second
  17.  
  18. using ll = long long;
  19. using pii = pair<int, int>;
  20. using pll = pair<ll, ll>;
  21. using vi = vector<int>;
  22.  
  23. constexpr ll MOD = 1e9 + 7;
  24.  
  25. inline ll pow_mod(ll a, ll b, ll mod = MOD)
  26. {
  27.     ll result = 1ll, mult = (a % mod);
  28.     while(b) {
  29.         if(b & 1) result = (result * mult) % mod;
  30.         mult = (mult * mult) % mod;
  31.         b /= 2ll;
  32.     }
  33.     return result;
  34. }
  35.  
  36. int main()
  37. {
  38.     vector<string> tests = {"a_example", "b_read_on", "c_incunabula", "d_tough_choices", "e_so_many_books", "f_libraries_of_the_world" };
  39.     ofstream out("testcase_analysis.csv");
  40.    
  41.     out << "test_name,distinct_books,total_libraries,available_days(D),average_signup_time,average_book_per_library" << endl;
  42.    
  43.     for(const auto& s : tests)
  44.     {
  45.         string in_name = s + ".txt";
  46.         ifstream in(in_name.c_str());
  47.         int b, l, d;
  48.         in >> b >> l >> d;
  49.          
  50.         vector<int> book_weight(b);
  51.         for(int& x : book_weight) in >> x;
  52.         int total_books = 0;
  53.         int total_signup = 0;
  54.         rep(i,0,l)
  55.         {
  56.             int n, t, m;
  57.             in >> n >> t >> m;
  58.             total_books += n;
  59.             total_signup += t;
  60.             int lixo;
  61.             rep(j, 0, n) in >> lixo;
  62.         }
  63.         in.close();
  64.         out << s << "," << b << "," << l << "," << d << "," <<  1.0 * total_signup / l << "," << 1.0 * total_books / l << endl;
  65.         /*cout << "Para o arquivo " << s << " temos os seguintes dados" << endl;
  66.         cout << "Total de Livros = " << b << endl;
  67.         cout << "Total de biblotecas = " << l << endl;
  68.         cout << "Media de livros por biblioteca = " << 1.0 * total_books / l << endl;
  69.         */
  70.     }
  71.     return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement