Submission #1501718
Source Code Expand
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cctype> #include<cstdlib> #include<algorithm> #include<bitset> #include<vector> #include<list> #include<deque> #include<queue> #include<map> #include<set> #include<stack> #include<cmath> #include<sstream> #include<fstream> #include<iomanip> #include<ctime> #include<complex> #include<functional> #include<climits> #include<cassert> #include<iterator> #include<unordered_set> #include<unordered_map> using namespace std; #define MAX 500002 string s; char buf[MAX]; vector<string> add; string pluss(string a, string b, bool flag = false) { if (!flag) { reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); } if (a.size() > b.size()) { swap(a, b); } string ans; ans.clear(); long long int want = 0; for (int i = 0; i < a.size(); i++) { long long int val = a[i] - '0'; val += b[i] - '0'; val += want; want = val / 10LL; val %= 10LL; ans.push_back(val + '0'); } for (int j = a.size(); j < b.size(); j++) { long long int val = 0; val += b[j] - '0'; val += want; want = val / 10LL; val %= 10LL; ans.push_back(val + '0'); } while (want) { ans.push_back(want % 10 + '0'); want /= 10; } if (!flag) { reverse(ans.begin(), ans.end()); } if (ans.size() == 0)ans = "0"; return ans; } string mult(string a, string b, bool flag = false) { if (!flag) { reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); } string ans = "0"; string pas; string kari; pas.clear(); for (int i = 0; i < b.size(); i++) { long long int bb = b[i] - '0'; long long int tmp = 0; kari = pas; for (int j = 0; j < a.size(); j++) { long long int val = (long long int)(a[j] - '0')*bb; val += tmp; tmp = val / 10LL; val %= 10LL; kari.push_back(val + '0'); } while (tmp) { kari.push_back((tmp % 10LL) + '0'); tmp /= 10LL; } ans = pluss(ans, kari, true); //end pas.push_back('0'); } if (!flag) { reverse(ans.begin(), ans.end()); } if (ans.size() == 0)ans = "0"; return ans; } string minuss(string a, string b) { reverse(b.begin(), b.end()); reverse(a.begin(), a.end()); while (a.size()>b.size()) { b.push_back('0'); } while (a.size()<b.size()) { a.push_back('0'); } bool carry = false; for (int i = 0; i<a.size(); i++) { if (a[i] != '0'&&carry) { a[i]--; carry = false; } if (a[i] == '0'&&carry) { a[i] = '9'; } if (a[i] >= b[i]) { a[i] = (a[i] - '0') - (b[i] - '0') + '0'; } else { a[i] = (10 + (a[i] - '0') - (b[i] - '0')) + '0'; carry = true; } } while (a.size()>1 && a.back() == '0') { a.pop_back(); } reverse(a.begin(), a.end()); return a; } int main() { scanf("%s", buf); s = buf; int i = 0; int ans = 0; while (i < s.size()) { if (s[i] == '0') { i++; continue; } //string f; int pr = -1; int be = i; while (i<s.size()&&pr <= s[i] - '0') { // f.push_back(s[i]); pr = s[i] - '0'; i++; } if (i != s.size()) { while (i-1>be&&i - 2 >= 0 && s[i - 1] - '0' == s[i - 2] - '0') { i--; // f.pop_back(); } //f.back()--; } /*for (int k = i; k < s.size(); k++) { f.push_back('9'); }*/ //cout << f << endl; //add.push_back(f); ans++; if (i == s.size()) { break; } int carry = 1; for (int j = s.size() - 1; j >= i; j--) { carry += s[j] - '0'; s[j] = carry % 10; s[j] += '0'; carry /= 10; if (carry == 0) { break; } } } cout << ans << endl; /*string K = "0"; for (int i = 0; i < add.size(); i++) { K = pluss(K, add[i]); } cout << K << endl;*/ return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Increasing Numbers |
User | Kmcode |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 3752 Byte |
Status | TLE |
Exec Time | 2103 ms |
Memory | 1280 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:139:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s", buf); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1300 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt, sample4.txt |
All | sample1.txt, sample2.txt, sample3.txt, sample4.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in3.txt, in30.txt, in31.txt, in4.txt, in5.txt, in500000.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | AC | 1 ms | 256 KB |
in10.txt | TLE | 2103 ms | 1152 KB |
in11.txt | AC | 5 ms | 1280 KB |
in12.txt | TLE | 2103 ms | 1280 KB |
in13.txt | TLE | 2103 ms | 1152 KB |
in14.txt | TLE | 2103 ms | 1152 KB |
in15.txt | TLE | 2103 ms | 1280 KB |
in16.txt | AC | 958 ms | 1280 KB |
in17.txt | AC | 4 ms | 1152 KB |
in18.txt | AC | 9 ms | 1280 KB |
in19.txt | AC | 7 ms | 1152 KB |
in2.txt | AC | 9 ms | 1280 KB |
in20.txt | AC | 4 ms | 1280 KB |
in21.txt | AC | 9 ms | 1280 KB |
in22.txt | AC | 9 ms | 1280 KB |
in23.txt | AC | 9 ms | 1280 KB |
in24.txt | TLE | 2103 ms | 1280 KB |
in25.txt | TLE | 2103 ms | 1152 KB |
in26.txt | AC | 9 ms | 1152 KB |
in27.txt | AC | 6 ms | 896 KB |
in28.txt | AC | 9 ms | 1280 KB |
in29.txt | AC | 9 ms | 1280 KB |
in3.txt | AC | 9 ms | 1280 KB |
in30.txt | AC | 9 ms | 1280 KB |
in31.txt | AC | 9 ms | 1280 KB |
in4.txt | AC | 9 ms | 1280 KB |
in5.txt | AC | 4 ms | 1280 KB |
in500000.txt | AC | 4 ms | 1280 KB |
in6.txt | AC | 9 ms | 1280 KB |
in7.txt | AC | 6 ms | 1024 KB |
in8.txt | AC | 4 ms | 1152 KB |
in9.txt | TLE | 2103 ms | 1152 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |
sample4.txt | AC | 1 ms | 256 KB |