AtCoder Beginner Contest 001

Submission #4237154

Source codeソースコード

//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
    if (!item.empty()) {
            elems.push_back(item);
        }
    }
    return elems;
}

int S[30010], E[30010];

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;

  REP(i, n){
    vector<string> vs;
    string str;
    cin >> str;
    vs = split(str, '-');
    S[i] = stoi(vs[0]);
    E[i] = stoi(vs[1]);
    if(S[i]%10 < 5) S[i] = S[i] - (S[i]%10);
    else if(S[i]%10 <= 9) S[i] = S[i] - (S[i]%10) + 5;

    if(E[i]%10 == 0) continue;
    else if(E[i]%10 <= 5) E[i] = E[i] - (E[i]%10) + 5;
    else if(E[i]%10 <= 9) E[i] = E[i] - (E[i]%10) + 10;
  }

  sort(S, S+n);
  sort(E, E+n);

  /*
  //check
  REP(i, n) cout << S[i] << endl;
  cout << "--" << endl;
  REP(i, n) cout << E[i] << endl;
  */
  
  vector<P> lr;
  lr.push_back(make_pair(S[0],E[0]));

  FOR(i,1,n){
    bool f = true;
    int tmp_l, tmp_r;
    tmp_l = S[i]; tmp_r = E[i];
    int ii=0;
    for(auto itr=lr.begin(); itr!=lr.end(); ++itr){
      /*
      cout << "i:" << i << " l: " << itr->first << " r: " << itr->second << endl;
      cout << "i:" << i << " tmp_l: " << tmp_l << " tmp_r: " << tmp_r << endl;
      */
      if(itr->first>tmp_r || itr->second<tmp_l) {
	//cout << "--1" << endl;			
	lr.push_back(make_pair(tmp_l,tmp_r));
	break;
      }
      if(tmp_l<itr->first && itr->second<tmp_r){
	//cout << "--2" << endl;		
	lr.erase(lr.begin()+ii, lr.begin()+ii+1);
	lr.push_back(make_pair(tmp_l,tmp_r));
	break;
      }
      if(itr->first <= tmp_r && tmp_l <= itr->first){
	//cout << "--3" << endl;	
	lr.erase(lr.begin()+ii, lr.begin()+ii+1);
	lr.push_back(make_pair(tmp_l,itr->second));
	break;
      }
      if(itr->second >= tmp_l && tmp_r >= itr->second){
	//cout << "--4" << endl;
	lr.erase(lr.begin()+ii, lr.begin()+ii+1);
	lr.push_back(make_pair(itr->first,tmp_r));
	break;
      }
      ii++;
    }
    
  }

  for(auto itr=lr.begin(); itr!=lr.end(); ++itr){
    string l = to_string(itr->first);
    while(l.size() < 4) l = '0'+l;    
    string r = to_string(itr->second);
    while(r.size() < 4) r = '0'+r;    
    cout << l << "-" << r << endl;
  }
  
  return 0;
}

Submission

Task問題 D - 感雨時刻の整理
User nameユーザ名 tikeda
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 3654 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
all 0 / 100 00_sample_01.txt,00_sample_02.txt,00_sample_03.txt,cho_cho_chokudai.txt,chokudai_ga_cho.txt,test_01.txt,test_02.txt,test_03.txt,test_04.txt,test_05.txt,test_06.txt,test_07.txt,test_08.txt,test_09.txt,test_10.txt,test_11.txt,test_12.txt,test_13.txt,test_14.txt,test_15.txt,test_16.txt,test_17.txt,test_18.txt,test_19.txt,test_20.txt,test_21.txt,test_22.txt,test_23.txt,test_24.txt,test_25.txt,test_26.txt,test_27.txt,test_28.txt,test_29.txt,test_30.txt,test_31.txt,test_32.txt,test_33.txt,test_34.txt,test_35.txt,test_36.txt,test_37.txt,test_38.txt,test_39.txt,test_40.txt,test_41.txt,test_42.txt,test_43.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_sample_01.txt AC 1 ms 256 KB
00_sample_02.txt AC 1 ms 256 KB
00_sample_03.txt AC 1 ms 256 KB
cho_cho_chokudai.txt WA
chokudai_ga_cho.txt AC 39 ms 512 KB
test_01.txt AC 2 ms 256 KB
test_02.txt AC 2 ms 256 KB
test_03.txt AC 2 ms 256 KB
test_04.txt AC 2 ms 256 KB
test_05.txt AC 2 ms 256 KB
test_06.txt AC 1 ms 256 KB
test_07.txt AC 1 ms 256 KB
test_08.txt AC 1 ms 256 KB
test_09.txt AC 2 ms 256 KB
test_10.txt AC 2 ms 256 KB
test_11.txt WA
test_12.txt AC 2 ms 256 KB
test_13.txt AC 1 ms 256 KB
test_14.txt AC 2 ms 256 KB
test_15.txt AC 2 ms 256 KB
test_16.txt WA
test_17.txt AC 2 ms 256 KB
test_18.txt AC 1 ms 256 KB
test_19.txt AC 3 ms 384 KB
test_20.txt AC 2 ms 256 KB
test_21.txt AC 37 ms 512 KB
test_22.txt AC 38 ms 512 KB
test_23.txt AC 37 ms 512 KB
test_24.txt AC 37 ms 512 KB
test_25.txt AC 37 ms 512 KB
test_26.txt WA
test_27.txt AC 35 ms 512 KB
test_28.txt WA
test_29.txt AC 1 ms 256 KB
test_30.txt WA
test_31.txt WA
test_32.txt WA
test_33.txt WA
test_34.txt AC 1 ms 256 KB
test_35.txt WA
test_36.txt AC 37 ms 512 KB
test_37.txt WA
test_38.txt WA
test_39.txt WA
test_40.txt WA
test_41.txt AC 35 ms 512 KB
test_42.txt AC 36 ms 512 KB
test_43.txt AC 35 ms 512 KB