Submission #846385

#TimeUsernameProblemLanguageResultExecution timeMemory
846385vjudge1KOVANICE (COI15_kovanice)C++98
10 / 100
2044 ms51956 KiB
#include<bits/stdc++.h> using namespace std; int main(){ long long a,b,c,d,e,t; scanf("%lld %lld %lld",&a,&b,&c); string kel; long long arr[b + 5]; vector <long long> es[b + 5]; queue <long long> que; vector <long long> ana; memset(arr,0,sizeof(arr)); string str[c + 5]; vector <pair <long long,long long> > adj[b + 5]; d=0; for(long long i=0;b>i;i++){ es[i].push_back(i); } for(long long i=0;c>i;i++){ char kl; long long h,m; scanf("%lld%c%lld",&h,&kl,&m); if(kl == '='){ adj[h-1].push_back(make_pair(m-1,0)); adj[m-1].push_back(make_pair(h-1,0)); } else{ adj[m-1].push_back(make_pair(h-1,1)); arr[h-1]++; } } for(long long i=0;b>i;i++){ if(arr[i] == 0){ ana.push_back(i); } } memset(arr,-1,sizeof(arr)); for(long long i=0;ana.size()>i;i++){ long long vis[b + 5]; memset(vis,0,sizeof(vis)); long long cakmaarr[b + 5]; memset(cakmaarr,-1,sizeof(cakmaarr)); que.push(ana[i]); cakmaarr[ana[i]] = 0; long long pivot,enb; enb=0; while(que.size()){ pivot = que.front(); que.pop(); if(vis[pivot] == 0){ vis[pivot] = 1; for(long long j=0;adj[pivot].size()>j;j++){ if(vis[adj[pivot][j].first] == 0 ){ cakmaarr[adj[pivot][j].first] = cakmaarr[pivot] + adj[pivot][j].second; if(enb < (cakmaarr[pivot] + adj[pivot][j].second)){ enb = cakmaarr[pivot] + adj[pivot][j].second; } que.push(adj[pivot][j].first); } } } } if(a == (enb + 1)){ for(long long j=0;b>j;j++){ if(cakmaarr[j] != -1){ arr[j]=cakmaarr[j]; } } } } for(long long i=0;b>i;i++){ if(arr[i] != -1){ printf("K%lld \n",(a - arr[i])); } else{ printf("?\n"); } } }

Compilation message (stderr)

kovanice.cpp: In function 'int main()':
kovanice.cpp:37:30: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   37 |  for(long long i=0;ana.size()>i;i++){
      |                    ~~~~~~~~~~^~
kovanice.cpp:52:39: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   52 |    for(long long j=0;adj[pivot].size()>j;j++){
      |                      ~~~~~~~~~~~~~~~~~^~
kovanice.cpp:4:18: warning: variable 'd' set but not used [-Wunused-but-set-variable]
    4 |  long long a,b,c,d,e,t;
      |                  ^
kovanice.cpp:4:20: warning: unused variable 'e' [-Wunused-variable]
    4 |  long long a,b,c,d,e,t;
      |                    ^
kovanice.cpp:4:22: warning: unused variable 't' [-Wunused-variable]
    4 |  long long a,b,c,d,e,t;
      |                      ^
kovanice.cpp:5:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |  scanf("%lld %lld %lld",&a,&b,&c);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
kovanice.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%lld%c%lld",&h,&kl,&m);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...