답안 #475135

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
475135 2021-09-21T09:30:41 Z Ahmed57 Sifra (COCI21_sifra) C++14
50 / 50
1 ms 204 KB
#include<bits/stdc++.h>
using namespace std;
int mod = 1000000007;
int main(){
    //ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //please help me in this problem xD
    string s,c;
    cin>>s;int ans = 0;
    map<string,int> mp;
    for(int i =0 ;i<s.size();i++){
        if(!isdigit(s[i])){
            if(!c.empty()){
                string f;bool ss = false;
                for(int j = 0;j<c.size();j++){
                    if(c[j]!='0')ss=true;
                    if(ss)f+=c[j];
                }
                if(f.empty())f="0";
                if(mp[f]==0){
                    mp[f] = 1;
                    ans++;
                }
                c = "";
            }
        }else c+=s[i];
    }
    if(!c.empty()){
        string f;bool ss = false;
        for(int j = 0;j<c.size();j++){
            if(c[j]!='0')ss=true;
            if(ss)f+=c[j];
        }
        if(f.empty())f="0";
        if(mp[f]==0){
            mp[f] = 1;
            ans++;
        }
        c = "";
    }
    cout<<ans<<"\n";
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:10:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i =0 ;i<s.size();i++){
      |                   ~^~~~~~~~~
Main.cpp:14:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |                 for(int j = 0;j<c.size();j++){
      |                               ~^~~~~~~~~
Main.cpp:29:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for(int j = 0;j<c.size();j++){
      |                       ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct