답안 #1089799

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1089799 2024-09-17T07:23:11 Z SalihSahin Sateliti (COCI20_satellti) C++14
0 / 110
1 ms 348 KB
#include<bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;

const int mod = 1e9 + 7;
const int inf = 1e9;
const int N = 2048;

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int n, m;
  cin>>n>>m;
  vector<vector<char> > a(n, vector<char>(m));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin>>a[i][j];
    }
  }

  vector<int> colp(m), rowp(n);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      colp[j] += (a[i][j] == '*');
      rowp[i] += (a[i][j] == '*');
    }
  }

  vector<pair<vector<int>, int> > bestrow(n), bestcol(m);
  int bestr = 0, bestc = 0;


  for(int i = 0; i < n; i++){
    vector<int> cand;
    for(int j = i; j < i + n; j++){
      cand.pb(rowp[j%n]);
    }
    bestrow[i] = {cand, i};
  }

  for(int i = 0; i < m; i++){
    vector<int> cand;
    for(int j = i; j < i + m; j++){
      cand.pb(colp[j%m]);
    }
    bestcol[i] = {cand, i};
  }

  sort(bestrow.rbegin(), bestrow.rend());
  sort(bestcol.rbegin(), bestcol.rend());
  bestr = bestrow[0].second;
  bestc = bestcol[0].second;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      cout<<a[(i + bestr)%n][(j + bestc)%m];
    }
    cout<<endl;
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -