12085 - Mobile Casanova

All about problems in Volume 120. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

dwittaq
New poster
Posts: 1
Joined: Thu Jul 07, 2016 4:23 pm

Re: 12085 - Mobile Casanova

Post by dwittaq »

Hi there,

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;
  }
}
EDIT: Offtopic, but is there a way to test compilation and execution of the code in a 32-bit system if one operates on a 64-bit system, excluding virtual machines? Any compiler flags?
Post Reply

Return to “Volume 120 (12000-12099)”