Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- using namespace std;
- /**
- * Auto-generated code below aims at helping you parse
- * the standard input according to the problem statement.
- **/
- int nodes1[500];
- int nodes2[500];
- int gateways[20];
- int nodesgateway1[500];
- int nodesgateway2[500];
- int nodesneargateway1[500];
- int nodesneargateway2[500];
- int main()
- {
- for (int i; i < 500; i++)
- {
- nodes1[i] = -100;
- nodes2[i] = -100;
- nodesgateway1[500] = -100;
- nodesgateway2[500] = -100;
- nodesneargateway1[500] = -100;
- nodesneargateway2[500] = -100;
- }
- for (int i; i < 20; i++)
- {
- gateways[i] = -100;
- }
- int N; // the total number of nodes in the level, including the gateways
- int L; // the number of links
- int E; // the number of exit gateways
- cin >> N >> L >> E; cin.ignore();
- for (int i = 0; i < L; i++) {
- int N1; // N1 and N2 defines a link between these nodes
- int N2;
- cin >> N1 >> N2; cin.ignore();
- nodes1[i] = N1;
- nodes2[i] = N2;
- }
- for (int i = 0; i < E; i++) {
- int EI; // the index of a gateway node
- cin >> EI; cin.ignore();
- }
- // game loop
- while (1) {
- int SI; // The index of the node on which the Skynet agent is positioned this turn
- cin >> SI; cin.ignore();
- for (int i; i < 500; i++)
- {
- if (nodes1[i] != -100 && nodes2[i] != -100)
- {
- for (int i2; i2 < 20; i2++)
- {
- if (nodes1[i] == gateways[i2] || nodes2[i] == gateways[i2])
- {
- nodesgateway1[i] = nodes1[i];
- nodesgateway2[i] = nodes2[i];
- }
- }
- }
- }
- for (int i; i < 500; i++)
- {
- if (nodes1[i] != -100 && nodes2[i] != -100)
- {
- if (nodes1[i] == nodesgateway1[i] || nodes2[i] == nodesgateway2[i] || nodes2[i] == nodesgateway1[i] || nodes1[i] == nodesgateway2[i])
- {
- nodesneargateway1[i] = nodes1[i];
- nodesneargateway2[i] = nodes2[i];
- }
- }
- }
- for (int i; i < 500; i++)
- {
- if (nodesgateway1[i] == SI || nodesgateway2[i] == SI) cout<<nodesgateway1[i]<<" "<<nodesgateway2[i]<<endl;
- else
- {
- if (nodesneargateway1[i] == SI || nodesneargateway2[i] == SI)
- {
- for (int i2; i2 < 500; i2++)
- {
- if (nodesgateway2[i2] == nodesneargateway1[i] || nodesgateway1[i2] == nodesneargateway2[i] || nodesgateway1[i2] == nodesneargateway1[i] || nodesgateway2[i2] == nodesneargateway2[i])
- {
- cout<<nodesgateway1[i2]<<" "<<nodesgateway2[i2]<<endl;
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement