I am also continuously getting WA on this problem, even though I have verified the answers to the sample inputs, the inputs found on uDebug and the inputs found in this thread. Might be something system specific. Any ideas?
Code: Select all
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <algorithm>
#define all(c) c.begin(),c.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
char tempc, tempc2;
int tempi, tempi2;
ll templl, templl2;
double tempd, tempd2;
string temps, temps2;
ll start = 0;
ll last = -2;
ll curr = 0;
void print_range()
{
if (start == last) {
cout << 0 << last << endl;
} else {
temps = to_string(start);
temps2 = to_string(last);
for (int i=0; i<temps.length(); i++) {
if (temps[i] != temps2[i]) {
cout << 0 << start << "-" << temps2.substr(i,temps.length()-i) << endl;
break;
}
}
}
}
int main ()
{
int case_num = 0;
while (++case_num) {
ll num_tpnums;
cin >> num_tpnums;
if (num_tpnums == 0) break;
cout << "Case " << case_num << ":" << endl;
for (int i=0; i<num_tpnums; i++) {
scanf("%lld",&curr);
if (curr != last+1) {
if (!(i==0)) {
print_range();
}
start = curr;
}
last = curr;
}
print_range();
cout << endl;
}
}