답안 #367199

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
367199 2021-02-16T14:16:49 Z bad_in_physics Sifra (COCI21_sifra) C++17
30 / 50
1 ms 364 KB
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

void solve() {
	string arr;
	cin>>arr;
	set<string> s;
	string ans = "";
	for (int i=0; i<arr.length(); i++) {
		if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
			ans += arr[i];
		} else {
			if (ans.length()>0) {
				s.insert(ans);
				//cout<<ans;
				ans = "";
			}
		}
	} ans = "";
	 for (int i = arr.length()-1; i>0; i--) {
		 if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
			 ans += arr[i];
		 } else {
			 reverse(ans.begin(),ans.end());
			 if (ans.length()>0) {
				 s.insert(ans);
			 }
			 break;
		 }
	 } /*for (auto i : s) {
		 cout<<i<<" ";
	 } */cout<<s.size();
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:11:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for (int i=0; i<arr.length(); i++) {
      |                ~^~~~~~~~~~~~~
Main.cpp:12:13: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   12 |   if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
Main.cpp:12:41: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   12 |   if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
Main.cpp:12:55: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   12 |   if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
Main.cpp:12:69: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   12 |   if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
Main.cpp:12:83: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   12 |   if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
Main.cpp:12:97: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   12 |   if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
Main.cpp:12:111: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   12 |   if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
Main.cpp:12:125: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   12 |   if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
Main.cpp:23:14: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   23 |    if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
Main.cpp:23:42: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   23 |    if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
Main.cpp:23:56: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   23 |    if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
Main.cpp:23:70: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   23 |    if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
Main.cpp:23:84: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   23 |    if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
Main.cpp:23:98: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   23 |    if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
Main.cpp:23:112: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   23 |    if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
Main.cpp:23:126: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   23 |    if (arr[i]=='1' | arr[i]=='2' | arr[i]=='3' | arr[i]=='4' | arr[i]=='5' | arr[i]=='6' | arr[i]=='7' | arr[i]=='8' | arr[i]=='9') {
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Incorrect 0 ms 364 KB Output isn't correct
8 Incorrect 0 ms 364 KB Output isn't correct
9 Correct 1 ms 364 KB Output is correct
10 Incorrect 1 ms 364 KB Output isn't correct