# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
846312 | 2023-09-07T13:24:48 Z | vjudge1 | KOVANICE (COI15_kovanice) | C++ | 54 ms | 71796 KB |
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); long long a,b,c,d; cin>>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++){ cin>>kel; if(kel[1] == '='){ adj[kel[2] - '1'].push_back(make_pair(kel[0] - '1',0)); adj[kel[0] - '1'].push_back(make_pair(kel[2] - '1',0)); } else{ adj[kel[2] - '1'].push_back(make_pair(kel[0] - '1',1)); arr[kel[0] - '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){ cout<<"K"<<a - arr[i]<<"\n"; } else{ cout<<"?\n"; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 856 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 31 ms | 41820 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 5 ms | 7004 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 54 ms | 71796 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |