Submission #375166

# Submission time Handle Problem Language Result Execution time Memory
375166 2021-03-09T03:54:48 Z div2der Sifra (COCI21_sifra) C++14
50 / 50
1 ms 364 KB
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

//#include <bits/stdc++.h>

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <iomanip>

using namespace std;

const int N = 1e6;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const int INF = 1e9 + 13;
const int NN = 2e3;

#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define eb emplace_back
#define ll long long

void init(const string &prob) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	if (prob != "default") {
		freopen((prob + ".txt").c_str(), "r", stdin);
		freopen((prob + ".txt").c_str(), "w", stdout);
	}
}

void solve() {
	string s;
	cin >> s;
	set <int> st;
	for (int i = 0; i < sz(s); ++ i) {
		if (s[i] - '0' <= 9 and s[i] - '0' >= 0)
			continue;
		else
			s[i] = '_';
	}
	int v = 0;
	bool ok = false;
	for (auto to : s) {
		if (to != '_') {
			ok = true;
			v += (to - '0');
			v *= 10;
		}
		else {
			if (ok) {
				st.insert(v / 10);
				v = 0;
				ok = false;
			}
			else
				continue;
		}
	}
	if (ok)
		st.insert(v / 10);
	cout << sz(st) << '\n';
	return;
}

int main() {
	init("default");
	int tt = 1;

	while (tt--) {
		solve();
	}
	return 0;
}

Compilation message

Main.cpp: In function 'void init(const string&)':
Main.cpp:32:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   32 |   freopen((prob + ".txt").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:33:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   33 |   freopen((prob + ".txt").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 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 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct