Submission #702138

# Submission time Handle Problem Language Result Execution time Memory
702138 2023-02-23T05:48:03 Z chenyan Cipele (COCI18_cipele) C++17
0 / 90
21 ms 5856 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb emplace_back
#define N 50010
map<string,int>m;
int a[2][N],cnt;
bitset<N>vis;
vector<int>g[N];
void dfs(int v){
	vis[v]=1;
	if(v<=1000)cnt++;
	for(int u:g[v]){
		if(vis[u])continue;
		dfs(u);
	}
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k,i,j,t=0,u,v;
	string s;
	cin>>n;
	for(u=0;u<2;u++){
		for(i=0;i<n;i++){
			cin>>s;
			int x=0;
			if(s[0]>='0'&&s[0]<='9'){
				for(j=1,k=0;k<s.size();j*=10,k++)
				x+=(s[s.size()-1-k]-'0')*j;
				a[u][i]=x;
			}
			else{
				if(!m[s])m[s]=(++t)+1000;
				a[u][i]=m[s];
			}
		}
	}
	for(i=0;i<n;i++)g[a[0][i]].pb(a[1][i]),g[a[1][i]].pb(a[0][i]);
	for(i=1;i<=1000;i++){
		cnt=0;
		dfs(i);
		if(cnt>1){
			cout<<"NE\n";
			return 0;
		}
	}
	cout<<"DA\n";
}

Compilation message

cipele.cpp: In function 'int main()':
cipele.cpp:33:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(j=1,k=0;k<s.size();j*=10,k++)
      |                 ~^~~~~~~~~
cipele.cpp:25:20: warning: unused variable 'v' [-Wunused-variable]
   25 |  int n,k,i,j,t=0,u,v;
      |                    ^
# Verdict Execution time Memory Grader output
1 Runtime error 18 ms 5708 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 21 ms 5856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1828 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 13 ms 5612 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 17 ms 5768 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 5732 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -