Submission #474674

# Submission time Handle Problem Language Result Execution time Memory
474674 2021-09-19T10:23:02 Z HossamHero7 Sateliti (COCI20_satellti) C++14
10 / 110
733 ms 796 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define endl '\n'
void solve(){
    int n,m;
    cin>>n>>m;
    vector <string> v(n);
    map <string,int> mp;
    for(auto &i:v) cin>>i;
    vector <string> ans;
    for(int i=0;i<n;i++){
        int mn = 0;
        string ans="";
        for(int shifJ=0;shifJ<=m*2;shifJ++){
            string temp = v[i];
            for(int j=0;j<m;j++){
                temp[(j+shifJ)%m] = v[i][j];
            }
            if(ans.size() == 0 || temp<ans){
                ans = temp;
                mn = shifJ;
            }
        }
        mp[v[i]] = mn;
    }

    for(int shifI=0;shifI<=n*2;shifI++){
        vector <string> v2;
        v2 = v;
        for(int i=0;i<n;i++){
            v2[(i+shifI)%n] = v[i];
        }
        int shifJ = mp[v2[0]];
        for(int i=0;i<n;i++){
            string temp = v[i];
            for(int j=0;j<m;j++){
                temp[(j+shifJ)%m] = v2[i][j];
            }
            v2[i] = temp;
        }
        if(ans.size() == 0 || v2<ans) ans = v2;
    }
    for(auto i : ans){
        cout<<i<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 332 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 5 ms 332 KB Output is correct
5 Correct 6 ms 332 KB Output is correct
6 Correct 4 ms 332 KB Output is correct
7 Correct 5 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 332 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 5 ms 332 KB Output is correct
5 Correct 6 ms 332 KB Output is correct
6 Correct 4 ms 332 KB Output is correct
7 Correct 5 ms 332 KB Output is correct
8 Correct 733 ms 796 KB Output is correct
9 Correct 13 ms 332 KB Output is correct
10 Correct 12 ms 332 KB Output is correct
11 Correct 716 ms 684 KB Output is correct
12 Incorrect 722 ms 684 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 332 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 5 ms 332 KB Output is correct
5 Correct 6 ms 332 KB Output is correct
6 Correct 4 ms 332 KB Output is correct
7 Correct 5 ms 332 KB Output is correct
8 Correct 733 ms 796 KB Output is correct
9 Correct 13 ms 332 KB Output is correct
10 Correct 12 ms 332 KB Output is correct
11 Correct 716 ms 684 KB Output is correct
12 Incorrect 722 ms 684 KB Output isn't correct
13 Halted 0 ms 0 KB -