| Task: | Lucky numbers |
| Sender: | OOliOO_slayer |
| Submission time: | 2016-09-13 18:14:04 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.05 s | details |
| #2 | ACCEPTED | 0.05 s | details |
| #3 | ACCEPTED | 0.06 s | details |
| #4 | WRONG ANSWER | 0.05 s | details |
| #5 | ACCEPTED | 0.06 s | details |
| #6 | ACCEPTED | 0.06 s | details |
| #7 | ACCEPTED | 0.05 s | details |
| #8 | ACCEPTED | 0.05 s | details |
| #9 | ACCEPTED | 0.05 s | details |
| #10 | ACCEPTED | 0.05 s | details |
| #11 | ACCEPTED | 0.05 s | details |
| #12 | ACCEPTED | 0.06 s | details |
| #13 | ACCEPTED | 0.06 s | details |
| #14 | ACCEPTED | 0.01 s | details |
| #15 | ACCEPTED | 0.05 s | details |
| #16 | ACCEPTED | 0.06 s | details |
| #17 | ACCEPTED | 0.05 s | details |
| #18 | ACCEPTED | 0.06 s | details |
| #19 | ACCEPTED | 0.05 s | details |
| #20 | ACCEPTED | 0.07 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:15:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int col =0; col < s.size(); col++) inp[col] = s[col] - '0';
^
input/code.cpp:23:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int col =1; col < s.size(); col++) {
^
input/code.cpp:35:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (col + 1 == s.size()) {
^Code
#include <vector>
#include <utility>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
string s; cin >> s;
if (s.size() == 1) {
cout << 0; return 0;
}
vector<int> inp(s.size());
for (int col =0; col < s.size(); col++) inp[col] = s[col] - '0';
vector<vector<int>> dp(10,vector<int>(s.size(), 1e9));
for (int row=0; row < 10; row++) {
dp[row][0] = 1;
}
dp[inp[0]][0] = 0;
int ans = 1e9;
for (int col =1; col < s.size(); col++) {
for (int row=0; row < 10; row++) {
for (int prev=0; prev< 10; prev++) {
if ((row + prev) % 7 == 0) {
int cand1 = dp[prev][col-1];
//cout << dp[col][col] << "qq" <<endl;
if (row != inp[col]) cand1++;
//cout << cand1 << " " << dp[row][col] << " qq " << row << " " << prev <<endl;
dp[row][col] = min(dp[row][col], cand1);
//cout << cand1 << " " << dp[row][col] << " qq2 " << row << " " << prev<<endl;
}
}
if (col + 1 == s.size()) {
//cout << dp[row][col] << "qwe" <<endl;
ans = min(ans, dp[row][col]);
}
}
}
cout << ans;
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 932 |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 622897 |
| correct output |
|---|
| 4 |
| user output |
|---|
| 4 |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 147656 |
| correct output |
|---|
| 3 |
| user output |
|---|
| 3 |
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| 3452 |
| correct output |
|---|
| 4 |
| user output |
|---|
| 2 |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 788431492 |
| correct output |
|---|
| 7 |
| user output |
|---|
| 7 |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 989266495048717272261061594909... |
| correct output |
|---|
| 48 |
| user output |
|---|
| 48 |
Test 7
Verdict: ACCEPTED
| input |
|---|
| 656115984810304444763175 |
| correct output |
|---|
| 18 |
| user output |
|---|
| 18 |
Test 8
Verdict: ACCEPTED
| input |
|---|
| 821785741859753883189643338604... |
| correct output |
|---|
| 49 |
| user output |
|---|
| 49 |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 989368021051 |
| correct output |
|---|
| 8 |
| user output |
|---|
| 8 |
Test 10
Verdict: ACCEPTED
| input |
|---|
| 850646258628472406299081311034... |
| correct output |
|---|
| 75 |
| user output |
|---|
| 75 |
Test 11
Verdict: ACCEPTED
| input |
|---|
| 905529028380409196254499360502... |
| correct output |
|---|
| 73 |
| user output |
|---|
| 73 |
Test 12
Verdict: ACCEPTED
| input |
|---|
| 910487086247939283017891549257... |
| correct output |
|---|
| 71 |
| user output |
|---|
| 71 |
Test 13
Verdict: ACCEPTED
| input |
|---|
| 819648081022975646379749170608... |
| correct output |
|---|
| 74 |
| user output |
|---|
| 74 |
Test 14
Verdict: ACCEPTED
| input |
|---|
| 534150835659907637615065081226... |
| correct output |
|---|
| 76 |
| user output |
|---|
| 76 |
Test 15
Verdict: ACCEPTED
| input |
|---|
| 903033794991942065956114372733... |
| correct output |
|---|
| 78 |
| user output |
|---|
| 78 |
Test 16
Verdict: ACCEPTED
| input |
|---|
| 737347217956895521599162105321... |
| correct output |
|---|
| 71 |
| user output |
|---|
| 71 |
Test 17
Verdict: ACCEPTED
| input |
|---|
| 826360887089984268785983647159... |
| correct output |
|---|
| 73 |
| user output |
|---|
| 73 |
Test 18
Verdict: ACCEPTED
| input |
|---|
| 224396467462996787526747118066... |
| correct output |
|---|
| 66 |
| user output |
|---|
| 66 |
Test 19
Verdict: ACCEPTED
| input |
|---|
| 162181307721411363866352372656... |
| correct output |
|---|
| 70 |
| user output |
|---|
| 70 |
Test 20
Verdict: ACCEPTED
| input |
|---|
| 885185290760073270713376396959... |
| correct output |
|---|
| 73 |
| user output |
|---|
| 73 |
