Submission #72654

# Submission time Handle Problem Language Result Execution time Memory
72654 2018-08-26T13:36:28 Z mhnd Simurgh (IOI17_simurgh) C++14
0 / 100
2 ms 384 KB
#include "simurgh.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N = 2e5+50;
const int oo = 1e9;
const int mod = 1e9+7;

vector<pair<int,int>> g[501];
bool taken[501];
map<int,int> used;

vector<int> find_roads(int n, vector<int> U, vector<int> V) {
	for(int i=0;i<U.size();i++){
		g[U[i]].push_back({V[i],i});
		g[V[i]].push_back({U[i],i});
	}
	vector<int> ans;
	for(int i=0;i<n;i++){
		for(int j=0;j<g[i].size();j++){
			int v = g[i][j].first;
			int w = g[i][j].second;
			if(taken[i] && taken[v])continue;
			taken[i]=taken[v]=1;
			used[w]=1;
			ans.push_back(w);
		}
	}
	int lst = count_common_roads(ans);
	for(int i=0;i<ans.size();i++){
		int cur = 0;
		taken[U[ans[i]]]=taken[V[ans[i]]]=0;
		for(int i=0;i<n;i++)cout << taken[i] << ' ';
		puts("");
		bool f=0;
		for(int j=g[U[ans[i]]].size()-1;j>=0;j--){
			int v = g[U[ans[i]]][j].first;
			int u = U[ans[i]];
			if(taken[u] && taken[v] || g[U[ans[i]]][j].second == i || used[g[U[ans[i]]][j].second])continue;
			cout << 1 << ' ' << u << ' ' << v << endl;
			int tmp = ans[i];
			ans[i] = g[U[ans[i]]][j].second;
			cur = count_common_roads(ans);
			if(cur > lst){
				taken[V[tmp]]=taken[U[tmp]]=0;
				taken[v]=taken[u]=1;
				used[ans[i]]=1;
				f=1;
				break;
			}
			ans[i] = tmp;
		}
		if(f)continue;
		for(int j=g[V[ans[i]]].size()-1;j>=0;j--){
			int v = g[V[ans[i]]][j].first;
			int u = V[ans[i]];
			if(taken[u] && taken[v] || g[V[ans[i]]][j].second == i)continue;
			cout << 2 << ' ' << u << ' ' << v << endl;
			int tmp = ans[i];
			ans[i] = g[V[ans[i]]][j].second;
			if(i==ans.size()-1)cout << ans[i] << endl;
			cur = count_common_roads(ans);
			if(cur > lst){
				taken[V[tmp]]=taken[U[tmp]]=0;
				taken[v]=taken[u]=1;
				used[ans[i]]=1;
				f=1;
				break;
			}
			ans[i] = tmp;
		}
		if(f)continue;
		taken[U[ans[i]]]=taken[V[ans[i]]]=1;
	}
	return ans;
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:17:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<U.size();i++){
              ~^~~~~~~~~
simurgh.cpp:23:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<g[i].size();j++){
               ~^~~~~~~~~~~~
simurgh.cpp:33:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<ans.size();i++){
              ~^~~~~~~~~~~
simurgh.cpp:42:16: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
    if(taken[u] && taken[v] || g[U[ans[i]]][j].second == i || used[g[U[ans[i]]][j].second])continue;
       ~~~~~~~~~^~~~~~~~~~~
simurgh.cpp:60:16: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
    if(taken[u] && taken[v] || g[V[ans[i]]][j].second == i)continue;
       ~~~~~~~~~^~~~~~~~~~~
simurgh.cpp:64:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(i==ans.size()-1)cout << ans[i] << endl;
       ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB Security Violation! Don't try to hack
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB Security Violation! Don't try to hack
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB Security Violation! Don't try to hack
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Security Violation! Don't try to hack
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB Security Violation! Don't try to hack
2 Halted 0 ms 0 KB -