]> Skullheadx's Git Forge - CCC.git/commitdiff
2018 S1, S2
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Wed, 5 Oct 2022 14:29:58 +0000 (10:29 -0400)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Wed, 5 Oct 2022 14:29:58 +0000 (10:29 -0400)
Main/C++/2018/S1.cpp [new file with mode: 0644]
Main/C++/2018/S1.exe [new file with mode: 0644]
Main/C++/2018/S1.o [new file with mode: 0644]
Main/C++/2018/S2.cpp [new file with mode: 0644]
Main/C++/2018/S2.exe [new file with mode: 0644]
Main/C++/2018/S2.o [new file with mode: 0644]

diff --git a/Main/C++/2018/S1.cpp b/Main/C++/2018/S1.cpp
new file mode 100644 (file)
index 0000000..f5cadc3
--- /dev/null
@@ -0,0 +1,31 @@
+#include <bits/stdc++.h>
+using namespace std;
+
+int main()
+{
+    int N, V;
+    cin >> N;
+
+    vector<int> road;
+
+    for (int i = 0; i < N; i++)
+    {
+        cin >> V;
+        road.push_back(V);
+    }
+
+    sort(road.begin(), road.end());
+
+    float min_size = -1, current_size, left, right;
+    for (int i = 1; i < N-1; i++)
+    {
+        left = (road[i] - road[i-1])/2.0;
+        right = (road[i+1] - road[i])/2.0;
+        current_size = left + right;
+        if (min_size == -1 || current_size < min_size)
+            min_size = current_size;
+    }
+   std::cout << std::fixed << std::setprecision(1) << min_size;
+
+    return 0;
+}
diff --git a/Main/C++/2018/S1.exe b/Main/C++/2018/S1.exe
new file mode 100644 (file)
index 0000000..948bb61
Binary files /dev/null and b/Main/C++/2018/S1.exe differ
diff --git a/Main/C++/2018/S1.o b/Main/C++/2018/S1.o
new file mode 100644 (file)
index 0000000..d5be192
Binary files /dev/null and b/Main/C++/2018/S1.o differ
diff --git a/Main/C++/2018/S2.cpp b/Main/C++/2018/S2.cpp
new file mode 100644 (file)
index 0000000..7b5f4d3
--- /dev/null
@@ -0,0 +1,79 @@
+#include <bits/stdc++.h>
+using namespace std;
+bool is_correct(vector<vector<int>> table, int n);
+vector<vector<int>> rotate_table(vector<vector<int>> table, int n);
+void print_table(vector<vector<int>> table, int n);
+
+int main()
+{
+    int N, input;
+    cin >> N;
+    vector<vector<int>> data;
+    for (int i = 0; i < N; i++)
+    {
+        vector<int> line;
+        for (int j = 0; j < N; j++)
+        {
+            cin >> input;
+            line.push_back(input);
+        }
+        data.push_back(line);
+    }
+
+
+    for (int i = 0; i < 3; i++)
+    {
+        if (is_correct(data,N)==true)
+            break;
+        else
+            data = rotate_table(data, N);
+    }
+
+    print_table(data, N);
+}
+
+void print_table(vector<vector<int>> table, int n)
+{
+    for (int i = 0; i < n; i++)
+    {
+        for (int j = 0; j < n; j++)
+        {
+            cout << table[i][j] << ' ';
+        }
+        cout << endl;
+    }
+}
+
+
+vector<vector<int>> rotate_table(vector<vector<int>> table, int n)
+{
+    vector<vector<int>> output;
+    for (int i = 0; i < n; i++)
+    {
+        vector<int> row;
+        for (int j = 0; j < n; j++)
+        {
+            row.push_back(table[j][i]);
+        }
+        reverse(row.begin(), row.end());
+        output.push_back(row);
+    }
+    return output;
+}
+
+
+bool is_correct(vector<vector<int>> table, int n)
+{
+    for (int i = 0; i < n; i++)
+    {
+        for (int j = 1; j < n; j++)
+        {
+            if (table[i][j] < table[i][j-1])
+                return false;
+            else if (table[j][i] < table[j-1][i])
+                return false;
+        }
+    }
+
+    return true;
+}
diff --git a/Main/C++/2018/S2.exe b/Main/C++/2018/S2.exe
new file mode 100644 (file)
index 0000000..c9b7b97
Binary files /dev/null and b/Main/C++/2018/S2.exe differ
diff --git a/Main/C++/2018/S2.o b/Main/C++/2018/S2.o
new file mode 100644 (file)
index 0000000..5c0730d
Binary files /dev/null and b/Main/C++/2018/S2.o differ