CSES - COCI 2007/2008 #2 - Results
Submission details
Task:Prva
Sender:henrikaalto
Submission time:2019-07-29 16:31:30 +0300
Language:C++ (C++17)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.01 sdetails
#3ACCEPTED0.01 sdetails
#4ACCEPTED0.01 sdetails
#5ACCEPTED0.01 sdetails
#6ACCEPTED0.01 sdetails
#7ACCEPTED0.01 sdetails
#8ACCEPTED0.01 sdetails

Code

#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
using ii=long long;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<string> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    string res = "zz";
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (i == 0 || v[i - 1][j] == '#') {
                string s;
                for (int it = i; it < n; ++it) {
                    if (v[it][j] == '#') break;
                    s.push_back(v[it][j]);
                }
                if (s.size() >= 2) res = min(res, s);
            }
            if (j == 0 || v[i][j - 1] == '#') {
                string s;
                for (int jt = j; jt < m; ++jt) {
                    if (v[i][jt] == '#') break;
                    s.push_back(v[i][jt]);
                }
                if (s.size() >= 2) res = min(res, s);
            }
        }
    }
    cout << res << "\n";
}

Test details

Test 1

Verdict: ACCEPTED

input
4 5
o#dnp
zji#f
v#d#a
e#a##

correct output
dida

user output
dida

Test 2

Verdict: ACCEPTED

input
5 6
#tyt##
zaaaaw
#l#q#w
zephz#
...

correct output
tales

user output
tales

Test 3

Verdict: ACCEPTED

input
7 4
rykj
xcm#
zz#o
#aaa
...

correct output
aaa

user output
aaa

Test 4

Verdict: ACCEPTED

input
8 8
wyhjkeor
eo#qyggz
cjpuelsd
sgqjzwkr
...

correct output
cjpuelsd

user output
cjpuelsd

Test 5

Verdict: ACCEPTED

input
10 15
#zzzzz#adobcxhc
p##guvawbwopsic
a#xzovd#kiclyht
#igrsqowa#bklwg
...

correct output
ado

user output
ado

Test 6

Verdict: ACCEPTED

input
15 15
tkys#tfoatosfdn
pcjjhgeoyylnikz
anvufh#b#hknkhf
cacdlmeypccffje
...

correct output
adulqbtwz

user output
adulqbtwz

Test 7

Verdict: ACCEPTED

input
19 19
##h#cng##x#d###d###
####f###p#####zdp#u
niiv#p######vupzp#n
p###f#####m#####t##
...

correct output
cf

user output
cf

Test 8

Verdict: ACCEPTED

input
20 20
jd#jlgsr#hwptyhapyaj
mh#obte#vaqj#g#gfihp
#soucejumbxoqkl#iqmq
lw#uprsn#i#dpxtob#gv
...

correct output
abfwlrt

user output
abfwlrt