Submission #258914

# Submission time Handle Problem Language Result Execution time Memory
258914 2020-08-06T18:08:50 Z itiam Slagalica (COCI19_slagalica2) C++11
0 / 70
1000 ms 2672 KB
#include <bits/stdc++.h>

using namespace std;
#define parii pair<int,int>
#define pb push_back

int n,rj[100007];
int l[8]={1,1,-1,-1,0,0,1,-1},d[8]={1,-1,1,-1,1,-1,0,0};
vector<parii> v;

int main(){
    int mog=0,lr=0,dr=0;
    cin >> n;
    for (int i=0;i<n;i++){
        int a,b;
        cin >> a >> b;
        if (a==5 || a==6){
            if (lr!=0){ cout << -1; return 0;}
            lr=a;rj[0]=b;mog+=l[a-1]+d[a-1];
        }
        else if (a==7 || a==8){
            if (dr!=0){ cout << -1; return 0;}
            dr=a;rj[n-1]=b;mog+=l[a-1]+d[a-1];
        }
        else{
            mog+=l[a-1]+d[a-1];
            v.pb({b,a});
        }
    }
    if (mog!=0){    cout << -1; return 0;}
    sort(v.begin(),v.end());
    int tmp=-1*d[lr-1],z=-1*l[dr-1],br=1;

    while(v.size()!=1){
        for (int i=0;i<v.size();i++){
            int sl=v[i].second;
            if (l[sl-1]==tmp){
                tmp=-1*d[sl-1];
                rj[br]=v[i].first;
                br+=1;
                v.erase(v.begin()+i);
                break;
            }
        }
    }
    rj[n-2]=v[0].first;
    for (int i=0;i<n;i++){
        if(i!=0)    cout << " ";
        cout << rj[i];
    }
    return 0;
}

Compilation message

slagalica.cpp: In function 'int main()':
slagalica.cpp:35:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i=0;i<v.size();i++){
                      ~^~~~~~~~~
slagalica.cpp:32:24: warning: unused variable 'z' [-Wunused-variable]
     int tmp=-1*d[lr-1],z=-1*l[dr-1],br=1;
                        ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Execution timed out 1089 ms 256 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 2544 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 2416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 82 ms 2544 KB Output is correct
2 Execution timed out 1093 ms 2672 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 72 ms 2420 KB Output is correct
2 Execution timed out 1086 ms 2416 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 2544 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 2416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 70 ms 2544 KB Output is correct
2 Execution timed out 1097 ms 2416 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 2544 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 2416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 2544 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 2416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 2420 KB Time limit exceeded
2 Halted 0 ms 0 KB -