Submission #1556322
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
ITR(i,begin(v),end(v)) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
ITR(i,begin(v),end(v)) is >> *i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template<class T>bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
before_main_function() {
#ifdef int
#undef INF
#define INF INFLL
#define stoi stoll
#endif
cin.tie(0);ios::sync_with_stdio(false);
cout<<setprecision(15)<<fixed;
// #define endl "\n"
}
} before_main_function;
//------------------8<------------------------------------8<--------------------
signed main() {
int n;
cin>>n;
vector<int> sum(1500,0);
REP(i,n) {
string str;
cin>>str;
auto getminute=[&](string t) {
int h=stoi(t.substr(0,2));
int m=stoi(t.substr(2,2));
m+=h*60;
return m;
};
string s=str.substr(0,4);
string e=str.substr(5,4);
int S=getminute(s);
int E=getminute(e);
if(S%5!=0) S=S/5*5;
if(E%5!=0) E=E/5*5+5;
sum[S]++;
sum[E+1]--;
}
REPF(i,1,1500) sum[i]+=sum[i-1];
int st=-1,en=-1;
vector<string> ans;
REP(i,1500) {
if(st==-1 && sum[i]>0) {
st=i;
}
if(st!=-1 && sum[i]<=0) {
en=i-1;
auto gentime=[](int m) {
int h=m/60;
m%=60;
stringstream ss;
ss<<setw(2)<<setfill('0')<<h;
ss<<setw(2)<<setfill('0')<<m;
return ss.str();
};
ans.push_back(gentime(st)+"-"+gentime(en));
st=-1;
}
}
cout<<ans<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
D - 感雨時刻の整理 |
User |
algon |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
2847 Byte |
Status |
AC |
Exec Time |
22 ms |
Memory |
256 KB |
Judge Result
Set Name |
all |
Score / Max Score |
100 / 100 |
Status |
|
Set Name |
Test Cases |
all |
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 |
Case Name |
Status |
Exec Time |
Memory |
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 |
AC |
19 ms |
256 KB |
chokudai_ga_cho.txt |
AC |
20 ms |
256 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 |
1 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 |
AC |
2 ms |
256 KB |
test_12.txt |
AC |
1 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 |
AC |
1 ms |
256 KB |
test_17.txt |
AC |
1 ms |
256 KB |
test_18.txt |
AC |
1 ms |
256 KB |
test_19.txt |
AC |
1 ms |
256 KB |
test_20.txt |
AC |
1 ms |
256 KB |
test_21.txt |
AC |
21 ms |
256 KB |
test_22.txt |
AC |
19 ms |
256 KB |
test_23.txt |
AC |
21 ms |
256 KB |
test_24.txt |
AC |
20 ms |
256 KB |
test_25.txt |
AC |
21 ms |
256 KB |
test_26.txt |
AC |
20 ms |
256 KB |
test_27.txt |
AC |
19 ms |
256 KB |
test_28.txt |
AC |
21 ms |
256 KB |
test_29.txt |
AC |
1 ms |
256 KB |
test_30.txt |
AC |
1 ms |
256 KB |
test_31.txt |
AC |
4 ms |
256 KB |
test_32.txt |
AC |
1 ms |
256 KB |
test_33.txt |
AC |
13 ms |
256 KB |
test_34.txt |
AC |
1 ms |
256 KB |
test_35.txt |
AC |
1 ms |
256 KB |
test_36.txt |
AC |
19 ms |
256 KB |
test_37.txt |
AC |
20 ms |
256 KB |
test_38.txt |
AC |
20 ms |
256 KB |
test_39.txt |
AC |
22 ms |
256 KB |
test_40.txt |
AC |
20 ms |
256 KB |
test_41.txt |
AC |
20 ms |
256 KB |
test_42.txt |
AC |
21 ms |
256 KB |
test_43.txt |
AC |
19 ms |
256 KB |