# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
252825 |
2020-07-26T10:20:53 Z |
Halit |
Izlet (COI19_izlet) |
C++17 |
|
2000 ms |
36548 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 3e3;
int subtask, n, arr[N+5][N+5], anc[N+5], color[N+5];
vector<int> t[N+5];
bool vis[N+5];
void dfs(int b,int x, int c, set<int> sz){
if(vis[x])
return;
vis[x] = 1;
sz.insert(color[x]);
if(arr[b][x] > sz.size()){
color[x]++;
sz.insert(color[x]);
}
for(int i = 0;i < t[x].size();i++){
if( (anc[t[x][i]] != x) && (anc[x] != t[x][i]))
continue;
dfs(b,t[x][i],c, sz);
}
}
int main(){
cin >> subtask >> n;
for(int i = 1;i <= n;i++)
color[i] = 1;
for(int i = 1;i <= n;i++)
for(int j = 1;j <= n;j++)
cin >> arr[i][j];
for(int i = 1;i <= n;i++){
for(int j = i+1;j <= n;j++){
if((arr[i][j] <= 2) && ((arr[i][j] == 1) + (anc[j] == 0) ) ){
anc[j] = i;
t[i].push_back(j);
t[j].push_back(i);
}
}
}
set<int> tmp;
for(int i = 1;i <= n;i++){
memset(vis,0, sizeof vis);
dfs(i,i,color[i],tmp);
}
for(int i = 1;i <= n;i++)
cout << color[i] << " \n"[i == n];
for(int i = 1;i <= n;i++){
for(int j = 0;j < t[i].size();j++){
if(anc[t[i][j]] != i)
continue;
cout << i << ' ' << t[i][j] << '\n';
}
}
}
Compilation message
izlet.cpp: In function 'void dfs(int, int, int, std::set<int>)':
izlet.cpp:14:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(arr[b][x] > sz.size()){
~~~~~~~~~~^~~~~~~~~~~
izlet.cpp:18:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0;i < t[x].size();i++){
~~^~~~~~~~~~~~~
izlet.cpp: In function 'int main()':
izlet.cpp:54:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j = 0;j < t[i].size();j++){
~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2099 ms |
36548 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |