Submission #873419

# Submission time Handle Problem Language Result Execution time Memory
873419 2023-11-15T04:54:22 Z vjudge1 Colors (RMI18_colors) C++17
0 / 100
53 ms 17240 KB
#include <bits/stdc++.h>
#define f first
#define S second
#define pb push_back
#define msk(x , y) ((x >> y) & 1)
#define all(x) x.begin() , x.end()
using namespace std;
typedef long long int ll;
const int N = 5e5 + 7;
const ll mod = 1e18;
const int dx[] = {-1,-1,1,1,2,-2,2,-2};
const int dy[] = {-2,2,2,-2,1,1,-1,-1};

int n , m , a[N] , b[N] , used[N];
vector <int > g[N];

void solve(){
	cin >> n >> m ;
	for(int i = 0 ; i <= n; i++) g[i].clear() , used[i] = 0;
	for(int i = 1 ; i <= n; i++)cin >> a[i];
	for(int i = 1 ; i <= n; i++)cin >> b[i];
	int rt = 0 ;
	for(int i = 1 ; i <= m; i++){
		int u , v;
		cin >> u >> v ;
		g[u].pb(v);
		g[v].pb(u);
		if(g[v].size() == n - 1) rt = v ;
		if(g[u].size() == n - 1) rt = u ;
	}
	for(int i = 1 ; i <= n; i++){
		if(a[rt] < b[i] && a[i] != b[i]){
			cout << "0\n";
			return ;
		}
		if(a[i] < b[i]){
			cout << "0\n";
			return ;
		}
		used[a[i]] = 1; 
	}
	for(int i = 1 ; i <= n; i++){
		if(used[b[i]]) continue ;
		cout << "0\n";
		return ;
	}
	cout << "1\n";
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);  
    cout.tie(0);
    int test=1;
    cin >> test ;
    for(int i=1;i<=test;i++){
//      cout << "Case " << i << ": ";
        solve();
     }
}

Compilation message

colors.cpp: In function 'void solve()':
colors.cpp:28:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |   if(g[v].size() == n - 1) rt = v ;
      |      ~~~~~~~~~~~~^~~~~~~~
colors.cpp:29:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |   if(g[u].size() == n - 1) rt = u ;
      |      ~~~~~~~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 17240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 16988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 16984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 16984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 17240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 16984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 16988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 17240 KB Output isn't correct
2 Halted 0 ms 0 KB -