Submission #151776

#TimeUsernameProblemLanguageResultExecution timeMemory
151776phillipTeoretičar (COCI18_teoreticar)C++14
0 / 130
526 ms28028 KiB
#include <bits/stdc++.h> using namespace std; int n,l,r,mx; vector<int>v[5009][2]; vector<pair<int,int> >p; int c[5009][5009]; bool vis[5009][2]; void dfs(int x,int id,int sc) { sc%=mx; for(int i=0;i<v[x][id].size();i++) { int y=v[x][id][i]; if(vis[y][1-id])continue; if(id==0)c[x][y]=sc; else c[y][x]=sc; vis[y][1-id]=1; dfs(y,1-id,sc+1); sc++; sc%=mx; } } int a[2]; int main() { cin>>a[0]>>a[1]>>n; for(int i=0;i<n;i++) { int x,y; cin>>x>>y; x--;y--; v[x][0].push_back(y); v[y][1].push_back(x); p.push_back({x,y}); } for(int j=0;j<2;j++) for(int i=0;i<a[j];i++) { int x=v[i][j].size(); mx=max(mx,x); } for(int j=0;j<2;j++) for(int i=0;i<a[j];i++) { if(vis[i][j])continue; vis[i][j]=1; dfs(i,j,0); } cout<<mx<<"\n"; for(int i=0;i<p.size();i++) { cout<<c[p[i].first][p[i].second]+1<<"\n"; } }

Compilation message (stderr)

teoreticar.cpp: In function 'void dfs(int, int, int)':
teoreticar.cpp:12:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<v[x][id].size();i++)
                 ~^~~~~~~~~~~~~~~~
teoreticar.cpp: In function 'int main()':
teoreticar.cpp:51:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<p.size();i++)
                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...