답안 #218966

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
218966 2020-04-03T10:13:54 Z brcode Zamjena (COCI18_zamjena) C++14
70 / 70
231 ms 25592 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+5;
map<string,vector<string>> v1;
string arr[MAXN];
string arr2[MAXN];
map<string,bool> vis;
string t = "";
string check(string x){
    char y = x[0];
    if(y>='0' && y<='9'){
        t = x;
        return x;
    }
    return "";
}
string glob ="";
string dfs(string curr){
    vis[curr] = true;
    string hold = check(curr);
    for(auto x:v1[curr]){
        if(!vis[x]){
            hold+=dfs(x);
        }
    }
    return hold;
}
int main() {
    int n;
    cin>>n;
    int cnt = 1;
    for(int i=1;i<=n;i++){
       cin>>arr[i];
    }
    for(int i=1;i<=n;i++){
        cin>>arr2[i];
    }
    for(int i=1;i<=n;i++){
        if(arr[i] == arr2[i]){
            continue;
        }
        v1[arr[i]].push_back(arr2[i]);
        v1[arr2[i]].push_back(arr[i]);
    }
    for(int i=1;i<=n;i++){
        if(vis[arr[i]]){
            continue;
        }
     
        
        auto hold = dfs(arr[i]);
        for(int j=0;j<hold.size();j++){
            for(int k=0;k<t.size();k++){
                if(hold[j+k]!=t[k]){
                    cout<<"NE"<<endl;
                    return 0;
                }
                
            }
            j+=hold.size()-1;
        }
    }
    cout<<"DA"<<endl;
}

Compilation message

zamjena.cpp: In function 'int main()':
zamjena.cpp:53:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<hold.size();j++){
                     ~^~~~~~~~~~~~
zamjena.cpp:54:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int k=0;k<t.size();k++){
                         ~^~~~~~~~~
zamjena.cpp:32:9: warning: unused variable 'cnt' [-Wunused-variable]
     int cnt = 1;
         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 12800 KB Output is correct
2 Correct 16 ms 12800 KB Output is correct
3 Correct 12 ms 12800 KB Output is correct
4 Correct 12 ms 12800 KB Output is correct
5 Correct 13 ms 12800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 12800 KB Output is correct
2 Correct 12 ms 12800 KB Output is correct
3 Correct 12 ms 12800 KB Output is correct
4 Correct 12 ms 12800 KB Output is correct
5 Correct 12 ms 12928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 12928 KB Output is correct
2 Correct 13 ms 12896 KB Output is correct
3 Correct 12 ms 12800 KB Output is correct
4 Correct 12 ms 12928 KB Output is correct
5 Correct 12 ms 12928 KB Output is correct
6 Correct 12 ms 12800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 13184 KB Output is correct
2 Correct 14 ms 13056 KB Output is correct
3 Correct 16 ms 13312 KB Output is correct
4 Correct 19 ms 13696 KB Output is correct
5 Correct 20 ms 13568 KB Output is correct
6 Correct 18 ms 13440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 15096 KB Output is correct
2 Correct 70 ms 17016 KB Output is correct
3 Correct 70 ms 18528 KB Output is correct
4 Correct 113 ms 20216 KB Output is correct
5 Correct 231 ms 25592 KB Output is correct
6 Correct 150 ms 21496 KB Output is correct