제출 #699495

#제출 시각아이디문제언어결과실행 시간메모리
699495Cross_RatioTeoretičar (COCI18_teoreticar)C++14
0 / 130
327 ms228548 KiB
#include <bits/stdc++.h> using namespace std; int num[500005]; array<int, 2> Edge[100005]; vector<int> adj[100005]; vector<int> adj2[100005]; int num_cnt = 0; int num1[100005]; int num2[100005]; bool pos[10005][10005]; signed main() { cin.sync_with_stdio(false); cin.tie(0); cout.tie(0); int L, R, M; cin >> L >> R >> M; int i, j; for(i=0;i<M;i++) { int a, b; cin >> a >> b; adj[a-1].push_back(b-1); adj2[b-1].push_back(a-1); Edge[i] = {a-1, b-1}; } for(i=0;i<=L;i++) { for(j=0;j<=10000;j++) pos[i][j] = true; } for(i=0;i<L;i++) { int cnt = 0; while(!pos[i][cnt]) cnt++; pos[i][cnt] = 0; num1[i] = cnt; for(int j : adj[i]) { for(int k : adj2[j]) pos[k][cnt] = false; } } for(i=0;i<=R;i++) { for(j=0;j<=10000;j++) pos[i][j] = true; } for(j=0;j<R;j++) { int cnt = 0; while(!pos[j][cnt]) cnt++; pos[j][cnt] = true; num2[j] = cnt; for(int i : adj2[j]) { for(int k : adj[i]) pos[k][cnt] = false; } } vector<int> idx; for(i=0;i<M;i++) { idx.push_back(num1[Edge[i][0]]^num2[Edge[i][1]]); num[i] = num1[Edge[i][0]]^num2[Edge[i][1]]; } sort(idx.begin(),idx.end()); idx.erase(unique(idx.begin(),idx.end()),idx.end()); for(i=0;i<M;i++) { num[i] = lower_bound(idx.begin(),idx.end(),num[i]) - idx.begin(); } cout << idx.size() << '\n'; for(i=0;i<M;i++) cout << num[i]+1 << '\n'; }
#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...