Today, when i submited a problem , it took 31ms .Then i wondered is there anyway faster than my way, so i went to dashboard and sort for the shortest execution time. There's a guy's code solved the problem only in 15ms, i copied his code and submit on my own but it took 31ms to execute. Can someone explain ???
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int n, m; cin >> n >> m;
int l = INT_MAX, r = INT_MIN, t = INT_MIN, b = INT_MAX;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
char c; cin >> c;
if (c == 'B') {
l = min(l, j);
r = max(r, j);
t = max(t, i);
b = min(b, i);
}
}
}
cout << (t + b) / 2 + 1 << " " << (l + r) / 2 + 1 << endl;
}
Because he is purple and you are green