답안 #366363

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
366363 2021-02-14T05:40:46 Z n00bie_1004 Sifra (COCI21_sifra) C++14
50 / 50
1 ms 364 KB
#include <bits/stdc++.h>
 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef long int li;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define test ll t; cin >> t; while(t--)
const long long int dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0}; 
const long long int cons = 100005, ncr_cons = 100005;
const long long int MOD = 1000000007; // const long long int MOD = 998244353; 
const long long int const_INT_MAX = 1000000000000000000, const_INT_MIN = -1 * 1000000000000000000;
using namespace std;
bool sortinrev(const pair<ll,ll> &a, const pair<ll,ll> &b){return (a.first > b.first);}
bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b){return (a.second < b.second);}
bool sortbysecinrev(const pair<ll,ll> &a, const pair<ll,ll> &b){return (a.second > b.second);}
ll gcd(ll x, ll y){return (ll)(__gcd(x, y));}   
ll lcm(ll x, ll y){return (ll)((x * y) / gcd(x, y));}
ll mod_expo(ll x, ll y, ll p){  
    if((x + p) % p == 0) return 0; 
    ll res = 1; x = (x + p) % p; 
    while (y > 0){   
        if(y & 1) res = (res*x + p) % p; 
        y = y>>1; x = (x*x + p) % p;  
    }  
    return res;    
}
void usaco(string str = ""){    
    fastio; 
    if(str.size()){ 
        freopen((str + ".in").c_str(), "r", stdin);  
        freopen((str + ".out").c_str(), "w", stdout); 
    }   
}  
char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; 
int main(){ 
    usaco(); 
    string s; cin >> s; ll n = s.size(); vector<ll> a(n, 0); 
    for(ll i=0;i<s.size();i++){
    	ll f=0; 
    	for(ll j=0;j<26;j++){
    		if(s[i] == alpha[j]) f=1;  
    	}
    	if(f) continue; 
    	else a[i] = 1; 
    } 
    set<ll> st;  
    vector<ll> dig; 
    for(ll i=0;i<n;i++){
    	if(i == n-1){
    		if(a[i]) dig.push_back((ll)(s[i] - '0')); 
    		if(dig.size() > 0){
    			ll cur_pow = 0, var=0; 
    			for(ll i=dig.size()-1;i>=0;i--){
    				var += dig[i] * pow(10, cur_pow); cur_pow++; 
    			}
    			st.insert(var); 
    		}
    		dig.clear(); 
    	}
    	else {
	    	if(a[i]) dig.push_back((ll)(s[i] - '0')); 
    		else {
    			if(dig.size() > 0){
	    			ll cur_pow = 0, var=0; 
	    			for(ll i=dig.size()-1;i>=0;i--){
	    				var += dig[i] * pow(10, cur_pow); cur_pow++; 
	    			}
	    			st.insert(var); 
    			}
    			dig.clear(); 
    		}
    	}
    }
    cout << (ll)(st.size()) << "\n";
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; 
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:39:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(ll i=0;i<s.size();i++){
      |                ~^~~~~~~~~
Main.cpp: In function 'void usaco(std::string)':
Main.cpp:31:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   31 |         freopen((str + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   32 |         freopen((str + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct