結果

問題 No.9006 マルチバイト文字テスト(テスト用)
ユーザー IL_mstaIL_msta
提出日時 2017-04-01 13:27:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,990 bytes
コンパイル時間 616 ms
コンパイル使用メモリ 66,592 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 02:02:12
合計ジャッジ時間 1,249 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
using namespace::std;

class UTF8{
public:
	int size;
	vector<string> str;
	UTF8(){
		size = 0;
		str.resize(0);
	}
	string operator[](int i){
		return str[i];
	}
	int set(string strInput){
		this->str = vector<string>(0);
		int len = strInput.size();
		unsigned char temp;
		for(int i=0;i<len;++i){
			temp = strInput[i];
			if( temp <= 0x7F ){//1バイト
				this->str.push_back( (string)(strInput.substr( i, 1 )) );
			}else if( 0xC2 <= temp && temp <= 0xDF ){//2バイト
				if( i+ 1 >= len ){
					this->size = this->str.size();
					return size;
				}
				this->str.push_back( strInput.substr( i, 2 ) );
				i += 1;
			}else if(0xE0 <= temp && temp <= 0xEF ){//3バイト
				if( i+2 >= len ){
					this->size = this->str.size();
					return size;
				}
				this->str.push_back( strInput.substr( i, 3 ) );
				i += 2;
			}else if(0xF0 <= temp && temp <= 0xF7 ){//4バイト
				if( i+3 >= len ){
					this->size = this->str.size();
					return size;
				}
				this->str.push_back( strInput.substr( i, 4 ) );
				i+= 3;
			}else if(0xF8 <= temp && temp <= 0xFB ){//5バイト
				if( i+4 >= len ){
					this->size = this->str.size();
					return size;
				}
				this->str.push_back( strInput.substr( i, 5 ) );
				i+= 4;
			}else if(0xFC <= temp && temp <= 0xFD ){//6バイト
				if( i+5 >= len ){
					this->size = this->str.size();
					return size;
				}
				this->str.push_back( strInput.substr( i, 6 ) );
				i+= 5;
			}
		}
		this->size = this->str.size();
		return this->size;
	}

	void operator=(UTF8 utf8){
		this->size = utf8.size;
		this->str = utf8.str;
	}
	void operator=(UTF8* utf8){
		this->size = utf8->size;
		this->str = utf8->str;
	}
	UTF8 operator+(string str_s){
		UTF8 ret;
		ret = this;
		ret.str.push_back(str_s);
		ret.size = ret.str.size();
		return ret;
	}
};

int main(void){
	string str;
	cin >> str;
	UTF8 utf;
	utf.set(str);
	int size = utf.size;
	for(int i=size-1;i>=0;--i){
		cout << utf[i];
	}
}
0