Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <sstream>
  4. #include <iomanip>
  5. #include <string>
  6. #include <algorithm>
  7. #include <cmath>
  8. #include <time.h>
  9. #include <vector>
  10. #include <stack>
  11. #include <queue>
  12. #include <set>
  13. #include <map>
  14. #include <cstdio>
  15. #include <assert.h>
  16. #include <cstdlib>
  17. #include <cstring>
  18.  
  19. using namespace std;
  20.  
  21. typedef long long ll;
  22. typedef double db;
  23. typedef string str;
  24.  
  25. #define forn(i, n) for (int i = 0; i < n; ++i)
  26. #define INF 1e+9
  27. #define EPS 1e-9
  28. #define PI 3.1415926535897932384626433832795
  29. #define mp(a, b) make_pair(a, b)
  30. #define pb(a) push_back(a)
  31. #define pii pair<int, int>
  32. #define pdd pair<db, db>
  33. #define sz(a) ( (int) a.size() )
  34. #define len(a) ( (int) a.length() )
  35. #define ms(x) memset(x, 0, sizeof(x))
  36. #define ms1(x) memset(x, -1, sizeof(x))
  37. #define L(a) sz(a)
  38. #define X first
  39. #define Y second
  40. #define ALL(a) a.begin(), a.end()
  41.  
  42.  
  43. int mat[310][40];
  44. int was[40];
  45. double I[40];
  46. int col[40];
  47. int R[40];
  48.  
  49. vector<string> rev;
  50. int main(){
  51. #ifdef _DEBUG
  52.     freopen("input.txt", "r", stdin);
  53.     //freopen("output.txt", "w", stdout);
  54. #else
  55.     freopen("ideal.in", "r", stdin);
  56.     freopen("ideal.out", "w", stdout);
  57. #endif
  58.  
  59.     string a;
  60.     int Teams = 0;
  61.     int Tasks = 0;
  62.     while(getline(cin,a)){
  63.         rev.pb(a);
  64.     }
  65.     int start = 0;
  66.     for(int i = L(rev)-1;i>=0;i--){
  67.         bool isother = false;
  68.         a = rev[i];
  69.         for(int j = 0;j < L(a);j++){
  70.             if(a[j]!='-' && a[j]!=' ')
  71.                 isother = true;
  72.         }
  73.         if(!isother && L(a)>0){
  74.             start = i + 1;
  75.             break;
  76.         }
  77.     }
  78.     int tem = start-2;
  79.     int raz = 0;
  80.     bool tw = false;
  81.     rev[tem]+=' ';
  82.     char must = 'A';
  83.     string cc = "";
  84.     for(int i = 0;i < L(rev[tem]);i++){
  85.         if(rev[tem][i]!=' '){
  86.             cc+=rev[tem][i];
  87.         }
  88.         if(rev[tem][i]==' '){
  89.             if(L(cc)==1 && cc[0]==must){
  90.                 must++;
  91.                 Tasks++;
  92.             }
  93.             cc = "";
  94.         }
  95.     }
  96.     while(start < L(rev)){
  97.         a = rev[start++];
  98.         int cur = Tasks-1;
  99.         bool was = false;
  100.         for(int j = L(a)-1;j>=0 && cur>=0;j--){
  101.             if(a[j]=='+'){
  102.                 mat[Teams][cur] = 1;
  103.                 cur--;
  104.                 was = true;
  105.             }
  106.             if(a[j]=='.' || a[j]=='-'){
  107.                 cur--;
  108.                 was = true;
  109.             }
  110.         }
  111.         reverse(ALL(a));
  112.         int rr = 0;
  113.         string tt = "";
  114.         for(int i = 0;i < L(a);i++){
  115.             if(a[i]>='0' && a[i]<='9'){
  116.                 tt+=a[i];
  117.             }else
  118.                 break;
  119.         }
  120.         reverse(ALL(tt));
  121.         for(int i = 0;i < L(tt);i++){
  122.             rr*=10;
  123.             rr+=tt[i]-'0';
  124.         }
  125.         R[Teams] = rr;
  126.         Teams++;
  127.     }
  128.  
  129.     double V = 0,O = 0,E = 0,U = 0,N = 0;
  130.     int n = Teams;
  131.     int m = Tasks;
  132.     int mxx = 0;
  133.     int mnn = INF;
  134.     ms1(was);
  135.     for(int i = n-1;i>=0;i--){
  136.         int cur = 0;
  137.         for(int j = 0;j < m;j++){
  138.             cur+=mat[i][j];
  139.             if(was[j]==-1){
  140.                 if(mat[i][j])
  141.                     was[j] = R[i];
  142.             }else{
  143.                 if(mat[i][j]==0 && was[j]>R[i]){
  144.                     I[j]+=1.0/n;
  145.                 }
  146.             }
  147.         }
  148.         col[cur] = 1;
  149.         if(cur==Tasks)
  150.             O+=1.0/n;
  151.         if(cur==0)
  152.             V+=1.0/n;
  153.         mxx = max(mxx,cur);
  154.         mnn = min(mnn,cur);
  155.     }
  156.     for(int i = mxx;i>mnn;i--){
  157.         if(col[i]==0)
  158.             E+=1.0/m;
  159.     }
  160.  
  161.     double T = 0;
  162.     for(int i = 0;i < Tasks;i++){
  163.         T+=I[i];
  164.         if(was[i]==-1)
  165.             U+=1.0/m;
  166.     }
  167.     N = 1.03*V+3.141*O+2.171*E + 1.414*U;
  168.     if(Tasks!=0)
  169.         T/=Tasks;
  170.     N+=T;
  171.  
  172.     printf("Vainness = %.5lf\n",V);
  173.     printf("Oversimplification = %.5lf\n",O);
  174.     printf("Evenness = %.5lf\n",E);
  175.     printf("Unsolvability = %.5lf\n",U);
  176.     for(int i = 0;i < m;i++){
  177.         printf("Instability %d = %.5lf\n",i+1,I[i]);
  178.     }
  179.     printf("Negidealness = %.5lf\n",N);
  180.  
  181.  
  182. #ifdef _DEBUG
  183.     cout << fixed << setprecision(15) << "\n" << clock() * 1.0 / CLOCKS_PER_SEC;
  184. #endif
  185.     return 0;
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement