Submission #45625948
Source Code Expand
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
vector <int> st[3][10];
string s[3];
int n,ans,s0,s1,s2,t0,t1,t2,c1,c2;
signed main()
{
cin >> n>> s[0]>> s[1]>> s[2];
s[0] += s[0]+s[0];
s[1] += s[1]+s[1];
s[2] += s[2]+s[2];
for(int k=0;k<3;k++)
for(int i=0;i<s[k].size();i++)
st[k][s[k][i]-'0'].push_back(i);
ans = 1e9;
for(int i=0;i<=9;i++)
{
if( st[0][i].size() != 0 && st[1][i].size() != 0 && st[2][i].size() != 0 )
{
s0 = st[0][i][0];
s1 = st[1][i][0];
s2 = st[2][i][0];
t0 = t1 = t2 = 0;
bool type = true;
while( s0 == s1 || s1 == s2 || s0 == s2 )
{
if( s0 == s1 )
{
if( t0 == st[0][i].size()-1 && t1 == st[1][i].size()-1 )
type = false;
if( t0 == st[0][i].size()-1 )
s1 = st[1][i][++t1];
else if( t1 == st[1][i].size()-1 )
s0 = st[0][i][++t0];
else if( st[0][i][t0+1] < st[1][i][t1+1] )
s0 = st[0][i][++t0];
else s1 = st[1][i][++t1];
}
if( s0 == s2 )
{
if( t0 == st[0][i].size()-1 && t2 == st[2][i].size()-1 )
type = false;
if( t0 == st[0][i].size()-1 )
s2 = st[2][i][++t2];
else if( t2 == st[2][i].size()-1 )
s0 = st[0][i][++t1];
else if( st[0][i][t0+1] < st[2][i][t2+1] )
s0 = st[0][i][++t0];
else s2 = st[2][i][++t2];
}
if( s1 == s2 )
{
if( t1 == st[1][i].size()-1 && t2 == st[2][i].size()-1 )
type = false;
if( t1 == st[1][i].size()-1 )
s2 = st[2][i][++t2];
else if( t2 == st[2][i].size()-1 )
s1 = st[1][i][++t1];
else if( st[1][i][t1+1] < st[2][i][t2+1] )
s1 = st[1][i][++t1];
else s2 = st[2][i][++t2];
}
if( type == false )
break;
}
if( type == false )
continue;
c1 = max( s0 , max( s1 , s2 ) );
ans = min( c1 , ans );
// printf("[%d] %d %d %d\n",i,s0,s1,s2);
}
}
printf("%d\n",ans==1e9?-1:ans);
// system("pause");
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Slot Strategy 2 (Easy) |
| User | itshawn3003 |
| Language | C++ 17 (gcc 12.2) |
| Score | 300 |
| Code Size | 2816 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 3796 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:17:22: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
17 | for(int i=0;i<s[k].size();i++)
| ~^~~~~~~~~~~~
Main.cpp:35:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
35 | if( t0 == st[0][i].size()-1 && t1 == st[1][i].size()-1 )
| ~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:35:55: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
35 | if( t0 == st[0][i].size()-1 && t1 == st[1][i].size()-1 )
| ~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:37:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
37 | if( t0 == st[0][i].size()-1 )
| ~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:39:33: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
39 | else if( t1 == st[1][i].size()-1 )
| ~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:48:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
48 | if( t0 == st[0][i].size()-1 && t2 == st[2][i].size()-1 )
| ~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:48:55: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
48 | if( t0 == st[0][i].size()-1 && t2 == st[2][i].size()-1 )
| ~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:50:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
50 | if( t0 == st[0][i].size()-1 )
| ~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:52:33: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
52 | else if( t2 == st[2][i].size()-1 )
| ~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:61:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
61 | if( t1 == st[1][i].size()-1 && t2 == st[2][i].size()-1 )
| ~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:61:55: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
61 | if( t1 == st[1][i].size()-1 && t2 == st[2][i].size()-1 )
| ~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:63:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
63 | if( t1 == st[1][i].size()-1 )
| ~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:65:33: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
65 | else if( t2 == st[2][i].size()-1 )
| ~~~^~~~~~~~~~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt |
| All | random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, sample_01.txt, sample_02.txt, sample_03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| random_01.txt | AC | 1 ms | 3792 KiB |
| random_02.txt | AC | 1 ms | 3572 KiB |
| random_03.txt | AC | 1 ms | 3792 KiB |
| random_04.txt | AC | 1 ms | 3712 KiB |
| random_05.txt | AC | 1 ms | 3660 KiB |
| random_06.txt | AC | 1 ms | 3616 KiB |
| random_07.txt | AC | 1 ms | 3788 KiB |
| random_08.txt | AC | 1 ms | 3616 KiB |
| random_09.txt | AC | 1 ms | 3780 KiB |
| random_10.txt | AC | 1 ms | 3784 KiB |
| random_11.txt | AC | 1 ms | 3792 KiB |
| random_12.txt | AC | 1 ms | 3656 KiB |
| random_13.txt | AC | 1 ms | 3632 KiB |
| random_14.txt | AC | 1 ms | 3628 KiB |
| random_15.txt | AC | 1 ms | 3640 KiB |
| random_16.txt | AC | 1 ms | 3784 KiB |
| random_17.txt | AC | 1 ms | 3716 KiB |
| random_18.txt | AC | 1 ms | 3772 KiB |
| random_19.txt | AC | 1 ms | 3640 KiB |
| random_20.txt | AC | 1 ms | 3652 KiB |
| random_21.txt | AC | 1 ms | 3796 KiB |
| random_22.txt | AC | 1 ms | 3788 KiB |
| random_23.txt | AC | 1 ms | 3608 KiB |
| sample_01.txt | AC | 1 ms | 3788 KiB |
| sample_02.txt | AC | 1 ms | 3796 KiB |
| sample_03.txt | AC | 1 ms | 3656 KiB |