Submission #494267


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

int main(){
  int n, m;
  char v[101][10001];
  int E[10001], W[10001]; //累積和

  cin >> n >> m;
  rep(i,m) rep(j,n) cin >> v[i][j];

  rep(j,n){
    int e_sum = 0, w_sum = 0;
    rep(i,m){
      if(v[i][j] == 'E') e_sum++;
      if(v[i][j] == 'W') w_sum++;
    }
    if(j == 0){E[j] = e_sum; W[j] = w_sum;}
    else{E[j] = E[j-1]+e_sum; W[j] = W[j-1]+w_sum;}
  }

  //  rep(i,n) cout << E[i] << " " << W[i] << endl;

  int ans = 0, sum = W[n-1];
  for(int i=1; i<n; i++){
    int sum_i = (W[n-1]-W[i-1]) + E[i-1];
    if(sum > sum_i){ans = i; sum = sum_i;}
  }
  if(sum > E[n-1]) ans = n;

  cout << ans << " " << ans+1 << endl;

  return 0;
}

Submission Info

Submission Time
Task A - Where is the Boundary
User mssn
Language C++11 (GCC 4.8.1)
Score 100
Code Size 769 Byte
Status AC
Exec Time 139 ms
Memory 2096 KiB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 26
Set Name Test Cases
All 00_sample_00, 00_sample_01, 00_sample_02, 00_sample_03, 01_random_small_00, 01_random_small_01, 01_random_small_02, 01_random_small_03, 01_random_small_04, 01_random_small_05, 02_random_large_00, 02_random_large_01, 02_random_large_02, 02_random_large_03, 02_random_large_04, 02_random_large_05, 03_random_biased_00, 03_random_biased_01, 03_random_biased_02, 03_random_biased_03, 04_random_reverse_biased_00, 04_random_reverse_biased_01, 04_random_reverse_biased_02, 04_random_reverse_biased_03, 05_min_00, 05_min_01
Case Name Status Exec Time Memory
00_sample_00 AC 31 ms 1056 KiB
00_sample_01 AC 29 ms 1056 KiB
00_sample_02 AC 29 ms 1048 KiB
00_sample_03 AC 27 ms 1056 KiB
01_random_small_00 AC 29 ms 948 KiB
01_random_small_01 AC 28 ms 948 KiB
01_random_small_02 AC 28 ms 1176 KiB
01_random_small_03 AC 29 ms 1080 KiB
01_random_small_04 AC 29 ms 1076 KiB
01_random_small_05 AC 29 ms 1080 KiB
02_random_large_00 AC 139 ms 2032 KiB
02_random_large_01 AC 134 ms 1976 KiB
02_random_large_02 AC 133 ms 2020 KiB
02_random_large_03 AC 138 ms 1968 KiB
02_random_large_04 AC 134 ms 2012 KiB
02_random_large_05 AC 135 ms 1972 KiB
03_random_biased_00 AC 132 ms 2076 KiB
03_random_biased_01 AC 133 ms 2080 KiB
03_random_biased_02 AC 131 ms 1972 KiB
03_random_biased_03 AC 136 ms 1972 KiB
04_random_reverse_biased_00 AC 135 ms 2080 KiB
04_random_reverse_biased_01 AC 136 ms 2096 KiB
04_random_reverse_biased_02 AC 135 ms 2092 KiB
04_random_reverse_biased_03 AC 135 ms 1972 KiB
05_min_00 AC 29 ms 940 KiB
05_min_01 AC 29 ms 1048 KiB