Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<fstream>
- #include<iomanip>
- #include<iostream>
- #include<array>
- #include<map>
- #include<vector>
- #include<algorithm>
- using namespace std;
- //size constant
- constexpr int x_size = 199, y_size = 319, k = 2;
- constexpr int fixed_x_size = x_size/k, fixed_y_size = y_size/k;
- template<typename T, int N> using A = array<T,N>;
- int main(){
- fstream fin("input.txt",ios::in);
- fstream fout("output.txt",ios::out);
- cin.rdbuf(fin.rdbuf());
- cout.rdbuf(fout.rdbuf());
- A<A<double,y_size>,x_size> arr;
- for(int i=0;i!=x_size;i++)
- for(int j=0;j!=y_size;j++)
- cin>>arr[i][j];
- // cout<<"debug 1"<<endl;
- A<A<double,fixed_y_size>,fixed_x_size> fixed_arr;
- // cout<<"debug 2"<<endl;
- for(int i=0;i!=fixed_x_size*k;i++)
- for(int j=0;j!=fixed_y_size*k;j++)
- fixed_arr[i/k][j/k]+=arr[i][j];
- // cout<<"debug 3"<<endl;
- for(auto& i:fixed_arr)
- for(auto& j:i)
- j/=k*k;
- map<double,long long> m;
- // cout<<"debug 4"<<endl;
- for(const auto& i:fixed_arr)
- for(const auto& j:i)
- m[j]++;
- using node=pair<double,long long>;
- vector<node> v;
- for(auto i=m.rbegin();i!=m.rend();i++)
- v.emplace_back(i->first,i->second);
- sort(v.begin(),v.end(),[](node a,node b){
- return a.second>b.second||(a.second==b.second&&a.first<b.first);
- });
- for(const auto& i:v)
- cout<<i.first<<", "<<i.second<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment