CSES - Putka Open 2015 – finaali - Results
Submission details
Task:Sanat
Sender:
Submission time:2015-12-20 15:35:22 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttimescore
#1--0details

Compiler report

input/code.cpp: In function 'int64_t dfs(const std::vector<node>&, std::vector<std::vector<std::pair<long int, long int> > >, std::vector<char>&, int64_t)':
input/code.cpp:19:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int64_t i=0;i<edges[cur].size();i++) {
                    ^
input/code.cpp: In function 'int main()':
input/code.cpp:52:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int64_t s=0;s<starts.size();s++) {
                    ^

Code

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

struct node {
  int64_t x,y;
};

typedef pair<int64_t,int64_t> P;

int64_t w;
int64_t dfs(const vector<node> &nodes, const vector<vector<P>> edges, vector<char> &used, int64_t cur) {
  if(nodes[cur].x == w) {
    return 1;
  }
  used[cur]=1;
  for(int64_t i=0;i<edges[cur].size();i++) {
    if(!used[edges[cur][i].second]) {
      if(dfs(nodes, edges, used, edges[cur][i].second)) {
        return 1;
      }
    }
  }
  used[cur]=0;
  return 0;
}

int main(void) {
  int64_t n,m;
  cin >> n >> m >> w;
  vector<node> nodes(n);
  vector<int64_t> starts;
  for(int64_t i=0;i<n;i++) {
    cin >> nodes[i].x >> nodes[i].y;
    if(nodes[i].x==0) starts.push_back(i);
  }
  vector<vector<pair<int64_t,int64_t>>> edges(n);
  for(int64_t i=0;i<m;i++) {
    int64_t a,b;
    cin >> a >> b;
    a--;b--;
    edges[a].push_back({nodes[b].y, b});
    edges[b].push_back({nodes[a].y, a});
  }
  for(int64_t i=0;i<n;i++) {
    sort(edges[i].begin(), edges[i].end());
  }
  int64_t cnt=0;
  vector<char> used(n);
  for(int64_t s=0;s<starts.size();s++) {
    cnt+=dfs(nodes, edges, used, starts[s]);
  }
  cout << cnt << endl;
}

Test details

Test 1

Verdict:

input
95000
pursua
zoomata
mantelilastu
jamming
...

correct output
10-4
10-4
10-4
QAQ
QAQ
...

user output
(empty)