Submission #45639961
Source Code Expand
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
int m;
string a, b, c;
cin >> m >> a >> b >> c;
int min_ = 100000;
size_t fb, fc;
for (size_t i = 0; i < a.size(); i++){
fb = b.find(a[i]);
if (fb == string::npos)
continue;
fc = c.find(a[i]);
if (fc == string::npos)
continue;
if(fb == i){
size_t prev = fb;
fb = b.find(a[i], fb + 1);
if (fb == string::npos){
fb = b.find(a[i]);
fb += m;
}
}
while(fc == fb || fc == i){
if (fc > m){
fc = fc % m;
}
size_t prev = fc;
fc = c.find(a[i], fc + 1);
if (fc == string::npos){
fc = c.find(a[i]);
fc += m;
}
cout << fc << endl;
}
min_ = min<int>(min_, max<int>(max<int>(i, fb), fc));
}
if (min_ == 100000){
cout << -1 << endl;
}else{
cout << min_ << endl;
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Slot Strategy 2 (Easy) |
| User | ThousandthStar |
| Language | C++ 17 (gcc 12.2) |
| Score | 0 |
| Code Size | 994 Byte |
| Status | WA |
| Exec Time | 2236 ms |
| Memory | 10076 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:23:14: warning: unused variable ‘prev’ [-Wunused-variable]
23 | size_t prev = fb;
| ^~~~
Main.cpp:32:14: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
32 | if (fc > m){
| ~~~^~~
Main.cpp:35:14: warning: unused variable ‘prev’ [-Wunused-variable]
35 | size_t prev = fc;
| ^~~~
Judge Result
| Set Name | Sample | All | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 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 | WA | 1 ms | 3536 KiB |
| random_02.txt | WA | 1 ms | 3468 KiB |
| random_03.txt | AC | 1 ms | 3608 KiB |
| random_04.txt | AC | 1 ms | 3460 KiB |
| random_05.txt | AC | 1 ms | 3604 KiB |
| random_06.txt | WA | 1 ms | 3664 KiB |
| random_07.txt | TLE | 2219 ms | 5304 KiB |
| random_08.txt | AC | 1 ms | 3396 KiB |
| random_09.txt | AC | 1 ms | 3528 KiB |
| random_10.txt | TLE | 2234 ms | 10024 KiB |
| random_11.txt | AC | 2 ms | 3404 KiB |
| random_12.txt | TLE | 2232 ms | 10008 KiB |
| random_13.txt | AC | 2 ms | 3472 KiB |
| random_14.txt | TLE | 2236 ms | 10060 KiB |
| random_15.txt | AC | 2 ms | 3528 KiB |
| random_16.txt | TLE | 2235 ms | 10076 KiB |
| random_17.txt | TLE | 2219 ms | 5260 KiB |
| random_18.txt | WA | 1 ms | 3552 KiB |
| random_19.txt | WA | 1 ms | 3444 KiB |
| random_20.txt | WA | 1 ms | 3520 KiB |
| random_21.txt | WA | 1 ms | 3532 KiB |
| random_22.txt | WA | 1 ms | 3460 KiB |
| random_23.txt | WA | 1 ms | 3604 KiB |
| sample_01.txt | WA | 1 ms | 3528 KiB |
| sample_02.txt | WA | 1 ms | 3600 KiB |
| sample_03.txt | AC | 1 ms | 3548 KiB |