Submission #267069

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
2670692020-08-15 19:01:46ChrisTTravelling Salesperson (CCO20_day2problem1)C++17
25 / 25
1422 ms24612 KiB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define all(x) (x).begin(),(x).end()
const int MN = 2e3 + 5;
bool adj[MN][MN];
int main () { //REEEEEE IM SO STUPID
int n;
scanf ("%d",&n);
for (int i = 2; i <= n; i++) {
for (int j = 1; j < i; j++) {
char c; scanf (" %c",&c); adj[i][j] = adj[j][i] = c == 'R';
}
}
if (n == 2) return !printf ("2\n1 2\n2\n2 1\n");
if (n == 3) return !printf ("3\n1 2 3\n3\n2 1 3\n3\n3 1 2\n");
for (int st = 1; st <= n; st++) { //idk just go in some order :tm:
int ed = -1;
vector<vector<int>> conn(n+1);
for (int i = 1; i <= n; i++) if (i != st) {
if (~ed) {
if (conn[ed].empty()) {
conn[ed].push_back(i); conn[i].push_back(ed);
continue;
}
if (conn[ed].size() == 1) {
int other = conn[ed][0];
conn[ed].push_back(i); conn[i].push_back(ed);
conn[other].push_back(i); conn[i].push_back(other);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |  scanf ("%d",&n);
      |  ~~~~~~^~~~~~~~~
Main.cpp:13:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |    char c; scanf (" %c",&c); adj[i][j] = adj[j][i] = c == 'R';
      |            ~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...