CSES - HIIT Open 2024 - Results
Submission details
Task:Hiitism
Sender:ht
Submission time:2024-11-16 12:58:25 +0200
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#10.00 sdetails
#20.00 sdetails
#30.00 sdetails
#40.00 sdetails
#50.00 sdetails
#6ACCEPTED0.01 sdetails
#70.01 sdetails
#80.01 sdetails
#90.01 sdetails
#100.01 sdetails
#110.01 sdetails
#120.01 sdetails
#130.01 sdetails
#14ACCEPTED0.01 sdetails
#15ACCEPTED0.01 sdetails
#160.01 sdetails
#170.01 sdetails
#18ACCEPTED0.01 sdetails
#190.01 sdetails
#200.01 sdetails
#210.01 sdetails
#220.01 sdetails
#23ACCEPTED0.01 sdetails
#24ACCEPTED0.01 sdetails
#25ACCEPTED0.01 sdetails
#260.01 sdetails
#27ACCEPTED0.01 sdetails
#28ACCEPTED0.01 sdetails
#290.01 sdetails
#300.01 sdetails

Compiler report

input/code.cpp: In function 'std::ostream& operator<<(std::ostream&, std::vector<std::vector<_Tp> >)':
input/code.cpp:10:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   10 |     for(const auto& x : v) os << x << " "; cout << "\n";} return os;
      |     ^~~
input/code.cpp:10:44: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   10 |     for(const auto& x : v) os << x << " "; cout << "\n";} return os;
      |                                            ^~~~

Code

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define rep(i,a,b) for(int i=a; i<=b; i++)
template<typename T> ostream& operator<<(ostream& os, const vector<T> v){ for(const auto& x : v) os << x << " "; return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>> y){
for(const auto& v : y){
for(const auto& x : v) os << x << " "; cout << "\n";} return os;
}
int findrow(vector<vector<char>>& s, ll n, ll m){
for(int i=0; i<n; i++){
char c = s[i][0];
if(c == '.')
continue;
bool x = true;
for(int j=1; j<m; j++){
if(s[i][j] != c){
x = false;
break;
}
}
if(x){
return i;
}
}
return -1;
}
int findcol(vector<vector<char>>& s, ll n, ll m){
for(int i=0; i<m; i++){
char c = s[0][i];
if(c == '.')
continue;
bool x = true;
for(int j=1; j<n; j++){
if(s[j][i] != c){
x = false;
break;
}
}
if(x){
// cout << "here: " << i << "\n" << s << "\n\n";
return i;
}
}
return -1;
}
int main(){
ios::sync_with_stdio(0);
vector<vector<char>> s;
ll n0,m0;
cin >> n0 >> m0;
ll n = n0, m = m0;
for(int i=0; i<n0; i++){
string s2;
cin >> s2;
vector<char> row;
for(int j=0; j<m0; j++){
row.push_back(s2[j]);
}
s.push_back(row);
// cout << row << "\n";
}
vector<int> ridxs;
vector<int> cidxs;
for(int i=0; i<n0; i++){
ridxs.push_back(i+1);
}
for(int i=0; i<m0; i++){
cidxs.push_back(i+1);
}
vector<string> res;
while(n>1 && m>1){
// cout << "\n\nthis:\n" << s << "\n\n";
int c = findrow(s, n, m);
if(c != -1){
string r;
r += "R "; r += to_string(ridxs[c]); r += " "; r += s[c][0];;
res.push_back(r);
// res << "R " << ridxs[c] << " " << s[c][0] << "\n";
s.erase(s.begin()+c);
n --;
ridxs.erase(ridxs.begin()+c);
continue;
}
c = findcol(s, n, m);
if(c != -1){
string r;
r += "C "; r += to_string(cidxs[c]); r += " "; r += s[0][c];
res.push_back(r);
// res << "C " << cidxs[c] << " " << s[0][c] << "\n";
for(int i=0; i<m; i++){
s[i].erase(s[i].begin() + c);
}
m --;
cidxs.erase(cidxs.begin()+c);
continue;
}
break;
}
for(const auto& v : s){
for(const auto& x : v){
if(x != '.'){
cout << "Impossible\n";
return 0;
}
}
}
// TODO: REverse output
res = vector(res.rbegin(), res.rend());
for(const auto& r : res)
cout << r << "\n";
// if here, impossible
}

Test details

Test 1

Verdict:

input
3 3
.H.
IHI
TTT

correct output
3
R 2 I
C 2 H
R 3 T

user output
R 2 I
C 2 H
R 3 T

Test 2

Verdict:

input
2 2
.H
IH

correct output
2
R 2 I
C 2 H

user output
Impossible

Test 3

Verdict:

input
10 10
T.TIH.....
IIIIIIIIII
T.TIH.....
TIIIHIIIII
...

correct output
7
C 3 T
R 10 I
R 4 I
C 5 H
...

user output
(empty)

Test 4

Verdict:

input
100 100
.............H........I.....IT...

correct output
19
R 3 T
C 44 H
R 34 I
C 30 T
...

user output
(empty)

Test 5

Verdict:

input
100 100
.........................H.......

correct output
Impossible

user output
(empty)

Test 6

Verdict: ACCEPTED

input
1000 1000
H.II..T.I.IH..I..H.I..I..ITHH....

correct output
Impossible

user output
Impossible

Test 7

Verdict:

input
1000 1000
HHHIHHHHHHHHHHHHIHHHHHHHHHHHHH...

correct output
Impossible

user output
(empty)

Test 8

Verdict:

input
1000 1000
IHIHTI.T.H..IHHIIT.I.TT.HH.HI....

correct output
1552
C 822 I
C 83 T
C 55 I
R 984 H
...

user output
(empty)

Test 9

Verdict:

input
1000 1000
HHHHHHHHHHHHHHHHHHHHHIHHHHHHHH...

correct output
1727
R 500 I
C 938 H
C 804 H
R 263 H
...

user output
(empty)

Test 10

Verdict:

input
1000 1000
TITTTHTITTHTHTHITTTTTTTHTHTTTI...

correct output
1856
C 22 H
R 531 T
C 412 H
C 288 H
...

user output
(empty)

Test 11

Verdict:

input
1000 1000
IHHTTTTHTIIIHTTTTHTIITTTHHITIT...

correct output
1826
R 200 H
R 167 I
C 445 I
C 355 I
...

user output
(empty)

Test 12

Verdict:

input
1000 1000
TTTTTITTTHTHTITIIHTIITIHTTIHTT...

correct output
Impossible

user output
(empty)

Test 13

Verdict:

input
1000 1000
TITHITITIITTIIIIIHIIIIHTIIIHTI...

correct output
Impossible

user output
(empty)

Test 14

Verdict: ACCEPTED

input
1000 1000
TTTTTTTTTTTTTTTTTTTITTTTTTTITT...

correct output
Impossible

user output
Impossible

Test 15

Verdict: ACCEPTED

input
1000 1000
IHTHHHIHIIIHHTTHHHHIHIIHHIHHHH...

correct output
Impossible

user output
Impossible

Test 16

Verdict:

input
1000 500
HIHHTHTITTHIHTHTTHIHTTIHTTHHTH...

correct output
1417
C 75 I
R 430 T
C 195 H
R 441 I
...

user output
Impossible

Test 17

Verdict:

input
500 1000
IHIIIHIIHIIIIIHIHHIIIIIIIIIIII...

correct output
1418
C 971 T
C 744 I
C 654 I
C 540 T
...

user output
(empty)

Test 18

Verdict: ACCEPTED

input
1000 500
IIIIIIIIIIIIIIITIIIIIIITTIIIII...

correct output
Impossible

user output
Impossible

Test 19

Verdict:

input
500 1000
HIITITHHHHIHHIHHTHIIIHHHHTHTHH...

correct output
Impossible

user output
(empty)

Test 20

Verdict:

input
1000 1000
TIITIIIIIIIIIIIIIIIIIHIHIIIIII...

correct output
Impossible

user output
(empty)

Test 21

Verdict:

input
1000 1000
TTHTTTTTHTTTHTTTTTTTTHHTTTTTIT...

correct output
Impossible

user output
(empty)

Test 22

Verdict:

input
1000 1000
IHIIIIITHIIIHIHHHITHIIIIHTTIHI...

correct output
Impossible

user output
(empty)

Test 23

Verdict: ACCEPTED

input
1000 1000
TTHIHIITHTI.HHIHHITIHIHIHIITIH...

correct output
Impossible

user output
Impossible

Test 24

Verdict: ACCEPTED

input
1000 1000
IHIHIIIIIIIIIHIIIHIHIITIHIIIII...

correct output
Impossible

user output
Impossible

Test 25

Verdict: ACCEPTED

input
1000 500
HIHITTIHITHHHTITHIHHHTHHIHHIII...

correct output
Impossible

user output
Impossible

Test 26

Verdict:

input
500 1000
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH...

correct output
Impossible

user output
(empty)

Test 27

Verdict: ACCEPTED

input
1000 500
TTTTIHTTTHTTHTITTTTHTHTTHTITTI...

correct output
Impossible

user output
Impossible

Test 28

Verdict: ACCEPTED

input
500 1000
HTIIIHIIIHITIHIIIIIIHTIIIIITHI...

correct output
Impossible

user output
Impossible

Test 29

Verdict:

input
1000 1000
.................................

correct output
0

user output
(empty)

Test 30

Verdict:

input
1000 1000
.................................

correct output
1
C 562 T

user output
C 562 T