Submission #242455

#TimeUsernameProblemLanguageResultExecution timeMemory
242455MatesV13Izlet (COI19_izlet)C++11
18 / 100
640 ms90364 KiB
#include <bits/stdc++.h> using namespace std; int sub, n, boje[3005][3005]; int b[3005], cur, par; vector<int> c[3005]; deque<pair<int, int> > xx; int main (){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> sub; if (sub==1){ cin >> n; for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) cin >> boje[i][j]; xx.push_front(make_pair(1, 0)); while(!xx.empty()){ cur = (xx.front()).first; par = (xx.front()).second; xx.pop_front(); if (b[cur]) continue; c[cur].push_back(par); c[par].push_back(cur); b[cur]=(b[par]+boje[cur][par])%2+1; for (int i=1; i<=n; i++){ if (b[i]) continue; if (boje[cur][i]==1) xx.push_front(make_pair(i, cur)); else xx.push_back(make_pair(i, cur)); } } for (int i=1; i<=n; i++) cout << b[i] << " "; cout << endl; for (int i=1; i<=n; i++){ for (int j=0; j<c[i].size(); j++){ if (boje[i][c[i][j]]){ cout << i << " " << c[i][j] << endl; boje[c[i][j]][i]=0; } } } } else if (sub==2){ cin >> n; for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) cin >> boje[i][j]; for (int i=1; i<=n; i++){ if (boje[i][1]==i) b[i]=i; else { for (int j=2; j<=i; j++) if (boje[i][j]==boje[i][j-1]){ b[i]=b[j-1]; break; } } } for (int i=1; i<=n; i++) cout << b[i] << " "; cout << endl; for (int i=1; i<n; i++) cout << i << " " << i+1 << endl; } else cout << "Sori, me is stupid!"; return 0; }

Compilation message (stderr)

izlet.cpp: In function 'int main()':
izlet.cpp:33:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j=0; j<c[i].size(); j++){
                 ~^~~~~~~~~~~~
izlet.cpp:56:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for (int i=1; i<=n; i++) cout << b[i] << " "; cout << endl;
  ^~~
izlet.cpp:56:48: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for (int i=1; i<=n; i++) cout << b[i] << " "; cout << endl;
                                                ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...