제출 #699474

#제출 시각아이디문제언어결과실행 시간메모리
699474Cross_RatioTeoretičar (COCI18_teoreticar)C++14
13 / 130
12072 ms44324 KiB
#include <bits/stdc++.h> using namespace std; int num[500005]; vector<array<int, 2>> adj[100005]; set<int> C[100005]; int num_cnt = 0; 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, i}); } for(i=0;i<L;i++) { set<int> S; for(auto n : adj[i]) { bool isPos = false; for(j=0;j<num_cnt;j++) { if(S.find(j) == S.end() && C[j].find(n[0])==C[j].end()) { num[n[1]] = j; C[j].insert(n[0]); S.insert(j); isPos = true; break; } } if(!isPos) { num[n[1]] = num_cnt; C[num_cnt].insert(n[0]); S.insert(num_cnt); num_cnt++; } } } cout << num_cnt << '\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...