Submission #951862

# Submission time Handle Problem Language Result Execution time Memory
951862 2024-03-22T20:55:11 Z Saul0906 PIN (CEOI10_pin) C++14
30 / 100
345 ms 26596 KB
#include <bits/stdc++.h>
#define rep(a,b,c) for(int a=b; a<c; a++)
#define repa(a,b) for(auto a:b)
#define fi first
#define se second
#define pii pair<int, int>
#define ll long long
#define endl "\n"

using namespace std;

struct trie{
	trie *nxt[36];
	int cont=0;
} *TR =  new trie;

void add(string s){
	trie *act=TR;
	int x;
	rep(i,0,s.size()){
		if(s[i]>'9' || s[i]<'0') x=s[i]-'a'+10;
		else x=s[i]-'0';
		if(!(act->nxt[x])) act->nxt[x]=new trie;
		act=act->nxt[x];
		act->cont++;
	}
}

int find(string s){
	trie *act=TR;
	int x;
	rep(i,0,s.size()){
		if(s[i]>'9' || s[i]<'0') x=s[i]-'a'+10;
		else x=s[i]-'0';
		if(!(act->nxt[x])) return 0;
		act=act->nxt[x];
	}
	return act->cont;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, d, ans=0;
	cin>>n>>d;
	string s[n], t;
	rep(i,0,n){
		cin>>s[i];
		t=s[i];
		rep(k,0,4){
			rep(j,0,10) if(j+'0'!=s[i][k]) t[k]=j+'0', ans+=find(t);
			rep(j,0,26) if(j+'a'!=s[i][k]) t[k]=j+'a', ans+=find(t);
			t[k]=s[i][k];
		}
		add(t);
	}
	cout<<ans<<endl;
}

Compilation message

pin.cpp: In function 'void add(std::string)':
pin.cpp:2:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    2 | #define rep(a,b,c) for(int a=b; a<c; a++)
......
   20 |  rep(i,0,s.size()){
      |      ~~~~~~~~~~~~                 
pin.cpp:20:2: note: in expansion of macro 'rep'
   20 |  rep(i,0,s.size()){
      |  ^~~
pin.cpp: In function 'int find(std::string)':
pin.cpp:2:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    2 | #define rep(a,b,c) for(int a=b; a<c; a++)
......
   32 |  rep(i,0,s.size()){
      |      ~~~~~~~~~~~~                 
pin.cpp:32:2: note: in expansion of macro 'rep'
   32 |  rep(i,0,s.size()){
      |  ^~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1368 KB Output is correct
2 Incorrect 4 ms 1228 KB Output isn't correct
3 Incorrect 3 ms 1116 KB Output isn't correct
4 Correct 62 ms 8276 KB Output is correct
5 Correct 81 ms 9904 KB Output is correct
6 Incorrect 81 ms 9996 KB Output isn't correct
7 Incorrect 62 ms 8192 KB Output isn't correct
8 Correct 91 ms 10820 KB Output is correct
9 Correct 164 ms 16468 KB Output is correct
10 Incorrect 204 ms 18196 KB Output isn't correct
11 Incorrect 85 ms 10412 KB Output isn't correct
12 Incorrect 184 ms 17196 KB Output isn't correct
13 Incorrect 98 ms 11628 KB Output isn't correct
14 Incorrect 94 ms 10668 KB Output isn't correct
15 Incorrect 183 ms 17236 KB Output isn't correct
16 Correct 174 ms 19080 KB Output is correct
17 Incorrect 314 ms 26532 KB Output isn't correct
18 Incorrect 208 ms 21180 KB Output isn't correct
19 Incorrect 241 ms 24100 KB Output isn't correct
20 Incorrect 345 ms 26596 KB Output isn't correct