/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 10ms 540.0 KiB
#3 Accepted 30ms 796.0 KiB
#4 Accepted 34ms 796.0 KiB
#5 Accepted 23ms 796.0 KiB
#6 Accepted 35ms 540.0 KiB
#7 Accepted 167ms 848.0 KiB
#8 Accepted 34ms 540.0 KiB
#9 Accepted 35ms 3.277 MiB
#10 Accepted 34ms 1.027 MiB
#11 Accepted 503ms 948.0 KiB
#12 Accepted 1601ms 2.461 MiB
#13 Accepted 333ms 2.328 MiB
#14 Accepted 15ms 3.855 MiB
#15 Accepted 514ms 2.461 MiB
#16 Accepted 17ms 2.773 MiB
#17 Accepted 19ms 3.57 MiB
#18 Accepted 1573ms 4.215 MiB
#19 Accepted 20ms 3.355 MiB
#20 Accepted 1342ms 3.449 MiB
#21 Time Exceeded ≥2091ms ≥4.27 MiB
#22 Time Exceeded ≥2098ms ≥4.312 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define F                first
#define S                second
#define pb               push_back
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define P(ok)            cout << (ok ? "YES\n": "NO\n")
#define __Heart__              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll>                   PII;
const int sz = 2005 ;
char grid[sz][sz] ;
int n , m ;
int countPlusLeft(int i , int j){
   int cnt = 0 ;
   while(j >= 0) {
    if(grid[i][j] != '+') break ;
    else cnt++ ;
    j-- ;
   }
   return cnt ;
}
int countPlusRight(int i , int j){
   int cnt = 0 ;
   while(j < m) {
    if(grid[i][j] != '+') break ;
    else cnt++ ;
    j++ ;
   }
   return cnt ;
}
int countPlusTop(int i , int j){
   int cnt = 0 ;
   while(i >= 0) {
    if(grid[i][j] != '+') break ;
    else cnt++ ;
    i-- ;
   }
   return cnt ;
}
int countPlusDown(int i , int j){
   int cnt = 0 ;
   while(i < n) {
    if(grid[i][j] != '+') break ;
    else cnt++ ;
    i++ ;
   }
   return cnt ;
}
void solve()
{
    int Ans = 0; cin >> n >> m ;
    for(int i = 0 ; i < n ; i++) for(int j = 0 ; j < m ; j++) cin >> grid[i][j] ;
    for(int i = 0 ; i < n ; i++) {
        for(int j = 0 ; j < m ; j++){
            if(grid[i][j] == '+') {
                int totPlus = min({countPlusLeft(i , j - 1) , countPlusRight(i , j + 1) , countPlusDown(i + 1 , j) , countPlusTop(i - 1 , j)}) * 4 ;
                Ans = max(Ans , 1 + totPlus ) ;
            }
        }
    }
    cout << Ans << "\n" ;
}
int main()
{
     __Heart__
     int t ; cin >> t ; while(t--) solve() ;
}

Information

Submit By
Type
Submission
Problem
P1143 Plus of Pluses
Contest
LU Divisonal Contest Problem Testing Round
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-08 02:12:10
Judged At
2024-12-08 02:12:10
Judged By
Score
60
Total Time
≥2098ms
Peak Memory
≥4.312 MiB