Submission #110401
Source Code Expand
#include <iostream> #include <stdio.h> using namespace std; struct TimeInfo { int start; int end; bool canCombain( TimeInfo &info ) { // 内包 if( start <= info.start ) { if( end >= info.end ) { return true; } else if( end >= info.start && end <= info.end ) { end = info.end; return true; } } else if( start <= info.end ) { if( end <= info.end ) { start = info.start; end = info.end; return true; } else { start = info.start; return true; } } return false; } }; int main() { // 整数の入力 int num; cin >> num; vector<TimeInfo> data; for( int i = 0;i < num;++i ) { string info; cin >> info; int start,end; start = end = 0; for( int i = 0;i < 4;++i ) { start = start * 10 + info[i]; end = end * 10 + info[(i + 5)]; } TimeInfo info; info.start = start; info.end = end; int j; for( j = 0;j < data.size();++j ) { if( data[j].start > start ) break; } data.insert( info, j ); } while( true ) { bool bCombain = false; for( int i = 0;i < data.size() - 1;++i ) { if( data[i].canCombain( data[i + 1] ) { bCombain = true; data.remove( i + 1 ); } } if( !bCombain ) break; } // 出力 for( int i = 0;i < data.size();++i ) { char output[16]; sprintf(output,"%04d-%04d",data[i].start,data[i].end); cout << output << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | interkame |
Language | C++ (G++ 4.6.4) |
Score | 0 |
Code Size | 1511 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:49:2: error: ‘vector’ was not declared in this scope ./Main.cpp:49:17: error: expected primary-expression before ‘>’ token ./Main.cpp:49:19: error: ‘data’ was not declared in this scope ./Main.cpp:62:12: error: conflicting declaration ‘TimeInfo info’ ./Main.cpp:52:10: error: ‘info’ has a previous declaration as ‘std::string info’ ./Main.cpp:63:8: error: ‘std::string’ has no member named ‘start’ ./Main.cpp:64:14: error: invalid use of member (did you forget the ‘&’ ?) ./Main.cpp:80:4: error: expected ‘)’ before ‘{’ token ./Main.cpp:84:3: error: expected primary-expression before ‘}’ token ./Main.cpp:84:3: error: expected ‘;’ before ‘}’ token